code for slope and intercept of a straight line

1 Ansicht (letzte 30 Tage)
bachir
bachir am 19 Okt. 2015
Kommentiert: bachir am 19 Okt. 2015
I keep getting "matrix dimensions must agree error" and error in line 2 here's my code below
% code
x =(-2:0.02:2);
y = (m*x)+b; <==================================line 2
m = input('enter the slope m');
b = input('enter the intercept b');
subplot(1,1,1)
plot(x,y,'r'), xlabel('x'),ylabel('y'), axis([-2 2 -1 1])

Akzeptierte Antwort

Image Analyst
Image Analyst am 19 Okt. 2015
Line 2 needs to come AFTER the m= and b= lines. How else will y know what they are???

Weitere Antworten (0)

Kategorien

Mehr zu Programming 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!

Translated by