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

36 views (last 30 days)
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

Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!