How to plot two variables in a single function?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (2)
Walter Roberson
am 27 Nov. 2016
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 Kommentare
KSSV
am 27 Nov. 2016
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 Kommentare
Siehe auch
Kategorien
Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!