plotting with variable parameter

31 ビュー (過去 30 日間)
Mesbahose Salekeen
Mesbahose Salekeen 2020 年 6 月 23 日
編集済み: Star Strider 2020 年 6 月 23 日
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?

採用された回答

Star Strider
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 —
.

その他の回答 (1 件)

Reeshabh Kumar Ranjan
Reeshabh Kumar Ranjan 2020 年 6 月 23 日
編集済み: Reeshabh Kumar Ranjan 2020 年 6 月 23 日

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by