Solving Physics+Matlab: Electric & Magnetic Fields

  • Context: MATLAB 
  • Thread starter Thread starter marko_4454
  • Start date Start date
  • Tags Tags
    Hard
Click For Summary

Discussion Overview

The discussion revolves around implementing a model of a charged particle moving through electric and magnetic fields using MATLAB. Participants are addressing specific questions related to simulating constant acceleration and analyzing the effects of electric and magnetic fields on the particle's motion.

Discussion Character

  • Homework-related
  • Mathematical reasoning
  • Technical explanation

Main Points Raised

  • One participant outlines the need to simulate a charged particle's motion under constant electric and magnetic fields, providing initial conditions and constants.
  • Another participant notes that the size mismatch between the time vector and the acceleration vector is causing issues in plotting.
  • A participant seeks clarification on how to maintain a constant acceleration value throughout the time vector in MATLAB.
  • There is a suggestion to plot individual components of acceleration or its magnitude to visualize the results correctly.

Areas of Agreement / Disagreement

Participants generally agree on the need to address the plotting issue in MATLAB, but there is no consensus on the best approach to implement the simulation or the expected results for the second question.

Contextual Notes

Participants express uncertainty about MATLAB syntax and the implications of vector sizes in plotting, indicating a need for further clarification on programming aspects related to the simulation.

marko_4454
Messages
2
Reaction score
0
For one of my classes I need to implement a model of a charged particle that is giong through electric and magnetic fields.
I can assume these constants:
m=1
q=1
x(0)=0
t-scan: [0 1]
Now the questions:
1)
Simulate the constant acceleration analytic case and plot the result. Add the analytic result from the plot to demostrate the agreement. Assume, E0=[1 0 0] (also E0=E, so constant)
;;My answer: I know that it will be constant because solving for a you get q/m[E+ v' x B] and all of them are constant, but I can't plot it in Matlab, because I have NEVER used it...

2)Solve for E(x)= [5 0 0] B(x)=[0 0 20] v0=[1 1 1]. Plot the position and velocity curves. Observe and measure the ExB drift. (hint: note the vector direction of the drift) and compare it to the expected analytic result--> (which i think its like a sin/cos curve)

Please, I really need to get this done and I have tried it, but I can't get this problem to work...

This is for problem #1
Code:
E = [1 0 0]; % define Po
t=0:.5:1; % make a vector L with 100 elements evenly spaced from 0 to 10
B=[1 0 0];
v=[0 0 0];

a2 = E+cross(v,B);

figure;
plot(t,a2);
It doesn't work...and I don't have any idea why...
I have NO idea for Question #2,,,so any help would be greatly appreachiated :)
 
Physics news on Phys.org
because the size of t and a2 do not match.
 
and how can I fix it?
acceleration doesn't depend on time so it has to be constant...but how can I put it, so that I say to MATLAB that I want "a" to be a certain value throughout the whole time..
Thanks for you help
 
marko_4454 said:
For one of my classes I need to implement a model of a charged particle that is giong through electric and magnetic fields.
I can assume these constants:
m=1
q=1
x(0)=0
t-scan: [0 1]
Now the questions:
1)
Simulate the constant acceleration analytic case and plot the result. Add the analytic result from the plot to demostrate the agreement. Assume, E0=[1 0 0] (also E0=E, so constant)
;;My answer: I know that it will be constant because solving for a you get q/m[E+ v' x B] and all of them are constant, but I can't plot it in Matlab, because I have NEVER used it...

2)Solve for E(x)= [5 0 0] B(x)=[0 0 20] v0=[1 1 1]. Plot the position and velocity curves. Observe and measure the ExB drift. (hint: note the vector direction of the drift) and compare it to the expected analytic result--> (which i think its like a sin/cos curve)

Please, I really need to get this done and I have tried it, but I can't get this problem to work...

This is for problem #1
Code:
E = [1 0 0]; % define Po
t=0:.5:1; % make a vector L with 100 elements evenly spaced from 0 to 10
B=[1 0 0];
v=[0 0 0];

a2 = E+cross(v,B);

figure;
plot(t,a2);
It doesn't work...and I don't have any idea why...
I have NO idea for Question #2,,,so any help would be greatly appreachiated :)

For 1, are you trying to plot the magnitude of the acceleration, or a single direction?

You can do figure;plot(t,a2(1)) to see the x-direction acceleration, and similarly figure; plot(t,a2(2)) and figure; plot(t,a2(3)) to see the y and z acceleration components. Or you could do figure; plot(t,norm(a)) to see the magnitude of the acceleration. You are having problems beacuse a2 is just a vector with 3 components, so when you say plot(t,a2) it tries to put one of the a2 components with each t value, which won't work unless t is the same size, and even then it won't give you what you want.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
2
Views
3K