how can i fix this error?

1 Ansicht (letzte 30 Tage)
furkan aktürk
furkan aktürk 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);

Akzeptierte Antwort

Burhan Burak AKMAN
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')

Weitere Antworten (0)

Kategorien

Mehr zu Entering Commands 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