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 个评论
Jan
2021-4-15
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
2021-4-15
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.
回答(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)
类别
在 帮助中心 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
