![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/320953/image.png)
plotting with variable parameter
조회 수: 17 (최근 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 —
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/320953/image.png)
.
댓글 수: 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
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!