plotting with variable parameter
44 次查看(过去 30 天)
显示 更早的评论
let's say i want to plot a graph f(x)=x^3+b*x^2+1
but i want to visualize the graph as b changes lets say from -3 to 3 with .5 step. How can i do it?
0 个评论
采纳的回答
Star Strider
2020-6-23
编辑:Star Strider
2020-6-23
Try this:
f = @(b,x) x.^3+b.*x.^2+1;
bv = -3:0.5:3; % Define ‘b’
x = linspace(-1, 1, 25); % Define ‘x’
[B,X] = ndgrid(bv,x);
F = f(B,X);
figure
plot(x, F)
lgdb = compose('%4.1f', bv);
lgd = legend(lgdb, 'Location','best')
title(lgd, 'b')
EDIT —
Added plot figure —
.
0 个评论
更多回答(1 个)
Reeshabh Kumar Ranjan
2020-6-23
编辑:Reeshabh Kumar Ranjan
2020-6-23
Hey Mesbahose,
I think this answers your question: https://in.mathworks.com/help/control/ug/build-app-with-interactive-plot-updates.html
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!