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

19 次查看(过去 30 天)
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

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by