필터 지우기
필터 지우기

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

조회 수: 19 (최근 30일)
Gabriel Venter
Gabriel Venter 2021년 4월 27일
댓글: Gabriel Venter 2021년 4월 27일
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