Recently started learning MatLab, trying to plot a function graph.
{2a+b=1
2a-b=7
I run this code, I get "Vectors must be the same length."
Error in Untitled2 (line 9)
plot(X,Y1,X,Y2);
Code:
A=[2,1;2,-1]
B=[1;7]
d=det(A)
X=inv(A)*B
A*X
X=-2:0.5:2;
Y1=(-2*A+1)/1;
Y2=(-2*A+7)/(-1);
plot(X,Y1,X,Y2);
grid on

 채택된 답변

Stephan
Stephan 2020년 10월 25일
편집: Stephan 2020년 10월 25일

0 개 추천

You overwrite X:
A=[2,1;2,-1]
B=[1;7]
d=det(A)
X=inv(A)*B
A*X
%X=-2:0.5:2;
Y1=(-2*A+1)/1;
Y2=(-2*A+7)/(-1);
plot(X,Y1,X,Y2);
grid on
To avoid this i commented the overwriting line out, because it is not used in the following code.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

태그

질문:

2020년 10월 25일

편집:

2020년 10월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by