Clear Filters
Clear Filters

ode45 - to a matrix

1 view (last 30 days)
Cillian
Cillian on 11 Jun 2012
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

Answers (0)

Community Treasure Hunt

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

Start Hunting!