ode45 - to a matrix

조회 수: 1 (최근 30일)
Cillian
Cillian 2012년 6월 11일
Hello.
I got another problem again. I want to get what ode45 returns to U:s first column of x-values, y-values and z-values. And the third to sixth rows should be the speeds in x-,y- and z-direction. But I have not succed to do that, can someone please tell me what I am doing wrong here.
Here is my code:
function f=magnet(~,B)
m=1;q=1;
a=1; b=0; c=0;
f=[(q/m*(b*B(3)-c*B(2)))
(-q/m(a*B(3)-c*B(1)))
q/m*(a*B(2)-b*B(1))];
x0=[1 0 0]';
v0=[0 1 0]';
u0=[x0;v0];
[~,U]=ode45(magnet,[0,6],u0);
U= zeros(6,3);
U(:, 1) = 1;
U(:, 2) = 2;
U(:, 3) = 3;
figure(1);
title('Homogentmagnetfalt')
legend('x-axeln', 'y-axeln')
xlabel('x-axeln')
ylabel('y-axeln')
plot3(U(:,1),U(:,2),U(:,3))
hold on
end
Thanks Regards Cillian

답변 (0개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by