how can i fix this error?

1 visualización (últimos 30 días)
furkan aktürk
furkan aktürk el 29 de Dic. de 2021
Respondida: Burhan Burak AKMAN el 29 de Dic. de 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);

Respuesta aceptada

Burhan Burak AKMAN
Burhan Burak AKMAN el 29 de Dic. de 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')

Más respuestas (0)

Categorías

Más información sobre Entering Commands en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by