Creating a for loop that uses different numbers for a variable for an ode function, and plotting those results

1 visualización (últimos 30 días)
Hello, I'm having trouble creating a for loop that would allow a variable in the code to change as it ran, so then I would have different results after a loop was completed. I keep getting an error that the arrays arent concatanated properly. The for loop would have to have a ode 45 function I had included but I'm getting confused in the for loop syntax. Im supposed to plot the result when ever the variable is changed, so four different plots on the same graph. Any help would be great. Thank You
  1 comentario
Walter Roberson
Walter Roberson el 3 de Nov. de 2019
What is the intention of
P=zeros(4,length(100));
? length(100) is length(a scalar) which is 1, so that is zeros(4,1)
P=P(i,j);
You replace all of P with one particular location in P. After the loop, P will be a scalar because of that, and P(i) will not exist for the plot() call.
Also, you are overwriting all of ts each iteration of the for loop. In this particular case you should be able to get away with that because you passed in a tspan that is a vector of length more than 2, in which the output times should be exactly the same as you passed in for tspan.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by