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

oltre 5 anni fa | 1

| accettato

Risposto
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

oltre 5 anni fa | 1

| accettato

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

oltre 5 anni fa | 1

| accettato

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

oltre 5 anni fa | 0

| accettato

Risposto
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

oltre 5 anni fa | 0

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

oltre 5 anni fa | 1

| accettato

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

oltre 5 anni fa | 1

| accettato

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

oltre 5 anni fa | 1

| accettato

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

oltre 5 anni fa | 1

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

oltre 5 anni fa | 0

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

oltre 5 anni fa | 1

| accettato

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

oltre 5 anni fa | 0

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

oltre 5 anni fa | 1

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

oltre 5 anni fa | 0

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

oltre 5 anni fa | 0

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

oltre 5 anni fa | 0

| accettato

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

oltre 5 anni fa | 1

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

oltre 5 anni fa | 1

| accettato

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

oltre 5 anni fa | 1

| accettato

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

oltre 5 anni fa | 0

| accettato

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

oltre 5 anni fa | 0

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

oltre 5 anni fa | 0

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

oltre 5 anni fa | 0

| accettato

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

oltre 5 anni fa | 0

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

oltre 5 anni fa | 0

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

oltre 5 anni fa | 0

| accettato

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

oltre 5 anni fa | 0

| accettato

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

oltre 5 anni fa | 0

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

oltre 5 anni fa | 0

| accettato

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

oltre 5 anni fa | 1

Carica altro