how can i fix this error?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
furkan aktürk
am 29 Dez. 2021
Beantwortet: Burhan Burak AKMAN
am 29 Dez. 2021
clc
clear
x (1)= 0;
y (1)= 3;
h = 0.05;
for i = 1:10
y (i+1)= y(i)+(6*x^2-3*x^2*y);
x (i+1)= x(i)+h;
end
plot(x,y,'-')
xlabel('x')
ylabel('y')
Error using ^ (line 52)
Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To perform elementwise matrix powers, use '.^'.
Error in odev1 (line 7)
y (i+1)= y(i)+(6*x^2-3*x^2*y);
0 Kommentare
Akzeptierte Antwort
Burhan Burak AKMAN
am 29 Dez. 2021
You need to change x to x(i) and y to y(i) like this code.
clc
clear
x (1)= 0;
y (1)= 3;
h = 0.05;
for i = 1:10
y (i+1)= y(i)+(6*x(i)^2-3*x(i)^2*y(i));
x (i+1)= x(i)+h;
end
plot(x,y,'-')
xlabel('x')
ylabel('y')
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Entering Commands 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!