How to index matrices inside a loop?
Hello, You can change your code a bit like this %% Quantum Control format long clear all clc %% Variables time = -20000...

bijna 5 jaar ago | 1

| accepted

Convert Column Vector to arrey matrix

bijna 5 jaar ago | 1

| accepted

Hello, Maybe you could try with another approach, for example, eq = @(y)2*log((((N-y)./(q*N)).^(N-y)).*((y./((1-q)*N)).^y)) ...

bijna 5 jaar ago | 1

| accepted

Index in position 1 exceeds array bounds (must not exceed 1).
Hello, There are several approaches that you can try to eleminate the point inside the circle. Here, I can show you a solution...

bijna 5 jaar ago | 0

| accepted

How can i average a 1-D array every n elements?
Hello, I think this function is exactly what you want https://www.mathworks.com/help/matlab/ref/movmean.html

bijna 5 jaar ago | 0

Solve out a symbol
Hello, If you write solve(k,s) the solve function will solve another equation k == 0, i.e, w*sqrt(e*m/2)*sqrt(sqrt(1+(s/(...

bijna 5 jaar ago | 1

| accepted

Not able to get plot
Hello, You used the linespace function with wrong parameter. Here is instruction of linespace function: linspace(X1, X2, N) ...

bijna 5 jaar ago | 1

| accepted

How can I define the time steps of an x-y plot?
Hello, To get the same figure, you should refine the time step and then you should store value of X and Y with respect to t be...

bijna 5 jaar ago | 1

| accepted

Counting the Same Occurance of a row string
Here is a possible solution that you can refer clear pj1 = { 'AVX', '0601' 'AVX', '0603' 'AVX', '0603' 'EPC', '0603' '...

bijna 5 jaar ago | 1

Access multiple folders and extract specific files
Hello, If I understood you well, the code below could help you clear root_folder = 1:12; fig_number = [4 8]; for i = 1:...

bijna 5 jaar ago | 0

How to extract specific rows from a text file?
Hello, Here is an solution that you can refer, clear FileName = 'HP1_ordered.txt'; NewFile = 'HP1_ordered_skip10.txt'; ...

bijna 5 jaar ago | 1

| accepted

i wanna improve my function
Hello, As guided by @Geoff Hayes, I could give an example code here. function [res] =contain(v,u) res=true; idx = find(u ==...

bijna 5 jaar ago | 0

Write to file inside a loop
Hello, You can refer a simple solution as follows saveb1 = []; for (your loop) your code to compute b1; ...

bijna 5 jaar ago | 1

Calculate volume below a 3D points
Hello, There is a problem with the interpolation function which is not good to give us a smooth fuction. If you plot the "inte...

bijna 5 jaar ago | 0

Taylor Series of e^x on point 1
Hello, At least, I found a mistake in your program. Let see the line T = symsum((F(o,1)*(x-p)^N)/factorial(N), N, 0, o); Th...

bijna 5 jaar ago | 0

Minimization of two variables
Hello, Here is an example for your problem, which you can refer clear xiyi = [0,1; 1,3; -1 2]; x0 ...

bijna 5 jaar ago | 0

| accepted

How can I get plot with smooth lines from this data?
Hello, There is an option that you can refer, a1 = smooth(a); plot(x,a1) There are many types of smooth function, you may ...

bijna 5 jaar ago | 1

Why the increment of plot not working ?
Hello, You shoul try to put figure('Position',[392,345,441,421]); surf(Data(:,:,i)); shading interp; view(2); % couldn;t a...

bijna 5 jaar ago | 1

| accepted

evaluate dynamic variables in a loop and assign each one with optimvar.
Hello, This small example may help you clear N = 3; b = cell(1,N); for i = 1:N a = sprintf('b%d',i); b{i} = ...

bijna 5 jaar ago | 1

| accepted

how to specify length on subplot
Hello, You could set xlim of the first figure. More details, you should see this https://it.mathworks.com/help/matlab/ref/...

bijna 5 jaar ago | 0

| accepted

Find argmin of function with unique vector
Hello, Here is an example that you can refer I find mininum of function , the initial guess is given by . The code could be ...

bijna 5 jaar ago | 0

For loop to extract every 3rd column out of matrix and assign as variable name
Hello, Here is an example that you can refer for i = 1:24 v = genvarname(['X' num2str(i)]); eval([v '= A(:,3*i);']); end ...

bijna 5 jaar ago | 0

Can i debug a for loop ?
Hello, In your code, you save variables "S" and "ab" with the same name for each loop. Therefore, the 'trajektorien.mat' only ...

bijna 5 jaar ago | 0

| accepted

Condition for matlab if
Hello How about if you remove semi-colon in the line if g(i)+20>size(Wscat,1);

bijna 5 jaar ago | 0

How can i fix ' Unable to perform assignment because the left and right sides have a different number of elements.' in the loop functions ?
Since "omega3" is a vector, which is not scalar and you calculate alpha3 by using omega3. So, I suggest you change "omge3" in ...

bijna 5 jaar ago | 0

Write a function ShowPrimes(n) that will find all prime numbers between 1 and n and return them as a vector. Do this using a for loop. Hint: use isprime(x) to check whether x is a prime number. As an example, >> primes=ShowPrimes(20) primes =
Hello, The idea is that you use isprime to check is this prime or not. Then, if it is the prime, you store the value of "i" ...

bijna 5 jaar ago | 0

| accepted

Find the minimum of a multi-variable function
Hello, In your code, it was not good to put the name like "fun(x,y)". Also, we do not need to declare "fx, fun, fy,.." as sym...

bijna 5 jaar ago | 0

| accepted

Plotting -3|siny|
it should be like that x=-3*abs(sin(y));

bijna 5 jaar ago | 0