calculating with many different parameters
Mostrar comentarios más antiguos
Hey MATLAB forum/community,
I am planning to plot a function with these condition. Is there any tips on how I do it?
a = 0:2:22
x = [1 2 3]
z = 0 : 0.1 : 0.4
y = x*z*a
I want to plot y with 1 value from z, 1 value from a, while showing all result for x = [1 2 3].
Thank you!
3 comentarios
Jan
el 15 de Abr. de 2021
What does "with constant z" mean, if z is [0 : 0.1 : 0.4]? Of course you can assign a scalar to z.
Fahrizal Perdana Fahmul
el 15 de Abr. de 2021
What exactly are you trying to do? What is the independent variable? What is the parameter that you're stepping? What sort of array size are you expecting on the output? What sort of plot do you intend?
I have to ask, because you're trying to multiply three vectors of different sizes:
y = x*z*a
and the only way I can imagine this working would be if it were rearranged to generate a 3D array.
Respuestas (1)
I want to plot y with 1 value from z, 1 value from a, while showing all result for x = [1 2 3].
To me, this sounds like you are trying to generate a plotted line for every possible pair (a(i),z(j)). That will generate a pretty boring set of plots in this case, but it is easily done:
a = 0:2:22;
z = 0 : 0.1 : 0.4;
slopes=z.'*a;
x = [1 2 3];
Y = x(:)*slopes(:).';
plot(x,Y)
Categorías
Más información sobre Annotations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
