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

mehr als 5 Jahre vor | 1

| akzeptiert

Beantwortet
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

mehr als 5 Jahre vor | 1

| akzeptiert

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

mehr als 5 Jahre vor | 1

| akzeptiert

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

mehr als 5 Jahre vor | 0

| akzeptiert

Beantwortet
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

mehr als 5 Jahre vor | 0

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

mehr als 5 Jahre vor | 1

| akzeptiert

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

mehr als 5 Jahre vor | 1

| akzeptiert

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

mehr als 5 Jahre vor | 1

| akzeptiert

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

mehr als 5 Jahre vor | 1

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

mehr als 5 Jahre vor | 0

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

mehr als 5 Jahre vor | 1

| akzeptiert

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

mehr als 5 Jahre vor | 0

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

mehr als 5 Jahre vor | 1

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

mehr als 5 Jahre vor | 0

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

mehr als 5 Jahre vor | 0

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

mehr als 5 Jahre vor | 0

| akzeptiert

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

mehr als 5 Jahre vor | 1

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

mehr als 5 Jahre vor | 1

| akzeptiert

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

mehr als 5 Jahre vor | 1

| akzeptiert

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

mehr als 5 Jahre vor | 0

| akzeptiert

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

mehr als 5 Jahre vor | 0

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

mehr als 5 Jahre vor | 0

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

mehr als 5 Jahre vor | 0

| akzeptiert

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

mehr als 5 Jahre vor | 0

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

mehr als 5 Jahre vor | 0

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

mehr als 5 Jahre vor | 0

| akzeptiert

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

mehr als 5 Jahre vor | 0

| akzeptiert

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

mehr als 5 Jahre vor | 0

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

mehr als 5 Jahre vor | 0

| akzeptiert

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

mehr als 5 Jahre vor | 1

Mehr laden