calculating with many different parameters

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
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.
I should revise the question.
I want to plot y with 1 value of z, 1 value of a, while showing all result for x = [1 2 3].
DGM
DGM el 15 de Abr. de 2021
Editada: DGM 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.

Iniciar sesión para comentar.

Respuestas (1)

Matt J
Matt J el 15 de Abr. de 2021
Editada: Matt J el 15 de Abr. de 2021
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

Productos

Versión

R2021a

Etiquetas

Preguntada:

el 15 de Abr. de 2021

Editada:

el 15 de Abr. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by