How to plot two variables in a single function?
조회 수: 3 (최근 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!