How to plot two variables in a single function?

3 Ansichten (letzte 30 Tage)
sashil dath
sashil dath am 27 Nov. 2016
Beantwortet: Walter Roberson am 27 Nov. 2016
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."

Antworten (2)

Walter Roberson
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)

KSSV
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.

Kategorien

Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by