How to plot two variables in a single function?
2 ビュー (過去 30 日間)
古いコメントを表示
How do I create a plot that shows the variation of k with respect to x in the following function without actually rearranging it? y-a*x + sin(b*x^2) + k*m=0
Assume the remaining terms have fixed values.
syms y a b k x
b*x^2 - a*x + y + k*m == 0
>> a=2, b=3,y=4;
>> x= 1:0.5:5;
>> plot(x,m)
The above code results in the following message "Error using plot Conversion to double from sym is not possible."
0 件のコメント
回答 (2 件)
Walter Roberson
2016 年 11 月 27 日
Your line
b*x^2 - a*x + y + k*m == 0
does not define anything. It creates an expression and prints the value of the expression to the screen, but it does not create any assignment.
Perhaps you want something like
eqn = b*x^2 - a*x + y + k*m == 0;
and then later
M = double( solve(subs(eqn), m) );
plot(x, M)
0 件のコメント
KSSV
2016 年 11 月 27 日
a=2, b=3,k=1:4;
x= 1:0.5:5;
X=zeros(length(k),length(x));
Y=zeros(length(k),length(x));
for i=1:length(k)
Y(i,:)= -b*x^2 +a*x-k(i)*m ;
end
plot(X,Y)
The above plots x,y for k = 1,2,3,4.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Creating, Deleting, and Querying Graphics Objects についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!