Borrar filtros
Borrar filtros

How to perform an operation on a whole column of a matrix?

19 visualizaciones (últimos 30 días)
Gabriel Venter
Gabriel Venter el 27 de Abr. de 2021
Comentada: Gabriel Venter el 27 de Abr. de 2021
I have the following code, which uses a variable y=1/r for the ODE. I want to convert back to using r, so thought that after solving with ode45 I could just perform the operation on the whole column and be fine, but it isn't working. Clearly I'm doing this wrong, as it runs fine but gives the complete wrong result.
Here is my code:
for i=1:20
G=i/20; %Saving that iterates value of G
[phi,y]=ode45(@(phi,y) odefunction1(phi,y,G), timerange, IC);
y(:,1)=1/(y(:,1)); %this is where I switch back to using r and save it as an element of the cell z. Issue is, its giving me compeltely the wrong result and returning 0 %everywhere for column 1 of y.
z{i}=y;
end

Respuestas (0)

Categorías

Más información sobre Programming 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