how can i fix this error?

2 vues (au cours des 30 derniers jours)
furkan aktürk
furkan aktürk le 29 Déc 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);

Réponse acceptée

Burhan Burak AKMAN
Burhan Burak AKMAN le 29 Déc 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')

Plus de réponses (0)

Catégories

En savoir plus sur Data Types dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by