Answered

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...

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...

12 månader ago | 1

| accepted

Answered

Convert Column Vector to arrey matrix

Hello, You may see this function, it will help you https://www.mathworks.com/help/matlab/ref/reshape.html

Convert Column Vector to arrey matrix

Hello, You may see this function, it will help you https://www.mathworks.com/help/matlab/ref/reshape.html

12 månader ago | 1

| accepted

Answered

solve not returning two answers

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)) ...

solve not returning two answers

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)) ...

12 månader ago | 1

| accepted

Answered

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...

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...

12 månader ago | 0

| accepted

Answered

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

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

12 månader ago | 0

Answered

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/(...

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/(...

12 månader ago | 1

| accepted

Answered

Not able to get plot

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

Not able to get plot

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

12 månader ago | 1

| accepted

Answered

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...

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...

12 månader ago | 1

| accepted

Answered

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' '...

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' '...

nästan ett år ago | 1

Answered

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:...

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:...

ungefär ett år ago | 0

Answered

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'; ...

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'; ...

ungefär ett år ago | 1

| accepted

Answered

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 ==...

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 ==...

ungefär ett år ago | 0

Answered

Write to file inside a loop

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

Write to file inside a loop

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

ungefär ett år ago | 1

Answered

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...

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...

ungefär ett år ago | 0

Answered

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...

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...

ungefär ett år ago | 0

Answered

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 ...

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 ...

ungefär ett år ago | 0

| accepted

Answered

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 ...

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 ...

ungefär ett år ago | 1

Answered

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...

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...

ungefär ett år ago | 1

| accepted

Answered

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} = ...

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} = ...

ungefär ett år ago | 0

| accepted

Answered

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/...

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/...

ungefär ett år ago | 0

| accepted

Answered

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 ...

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 ...

ungefär ett år ago | 0

Answered

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 ...

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 ...

ungefär ett år ago | 0

Answered

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 ...

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 ...

ungefär ett år ago | 0

| accepted

Answered

Condition for matlab if

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

Condition for matlab if

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

ungefär ett år ago | 0

Answered

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 ...

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 ...

ungefär ett år ago | 0

Answered

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" ...

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" ...

ungefär ett år ago | 0

| accepted

Answered

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...

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...

ungefär ett år ago | 0

| accepted

Answered

Rearrange any matrix Randomly with a specific sequence

Here is an example that you can refer a = 1:20; b = randperm(4); n = length(b); for i = 1:n c(5*(i-1)+1:5*i) = a(5*(b(i)-1...

Rearrange any matrix Randomly with a specific sequence

Here is an example that you can refer a = 1:20; b = randperm(4); n = length(b); for i = 1:n c(5*(i-1)+1:5*i) = a(5*(b(i)-1...

ungefär ett år ago | 0

| accepted

Answered

How to get line number in a text file with a specific word

Hello, you could try this fileID = fopen('fruit.txt','r'); A = textscan(fileID,'%s'); fclose(fileID); n = size(A{:}); fo...

How to get line number in a text file with a specific word

Hello, you could try this fileID = fopen('fruit.txt','r'); A = textscan(fileID,'%s'); fclose(fileID); n = size(A{:}); fo...

ungefär ett år ago | 1