calculating with many different parameters
1 view (last 30 days)
Show older comments
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 Comments
DGM
on 15 Apr 2021
Edited: DGM
on 15 Apr 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.
Answers (1)
Matt J
on 15 Apr 2021
Edited: Matt J
on 15 Apr 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)
0 Comments
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!