Solving Physics+Matlab: Electric & Magnetic Fields

  • MATLAB
  • Thread starter marko_4454
  • Start date
  • Tags
    Hard
In summary: To get what you want, you need to explicitly specify which component of a2 you want to plot for each t value.
  • #1
marko_4454
2
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
  • #2
because the size of t and a2 do not match.
 
  • #3
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
 
  • #4
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.
 

Related to Solving Physics+Matlab: Electric & Magnetic Fields

1. What is the purpose of using Matlab in solving electric and magnetic fields?

Matlab is a powerful computational tool that allows for efficient and accurate calculations of electric and magnetic fields. It can handle complex equations and perform simulations, making it an essential tool for solving physics problems.

2. How do electric and magnetic fields interact with each other?

Electric and magnetic fields are closely related and can influence each other. When an electric field changes, it produces a magnetic field, and vice versa. This phenomenon is known as electromagnetic induction and is the basis for many technologies, such as generators and motors.

3. What are some common applications of solving electric and magnetic fields?

Electric and magnetic fields have numerous applications in our daily lives, such as in electronics, power generation, and medical equipment. They are also used in research and development in fields like aerospace, materials science, and renewable energy.

4. What are some techniques for solving electric and magnetic fields using Matlab?

There are several techniques for solving electric and magnetic fields using Matlab, including the finite element method, the boundary element method, and the finite difference method. These methods involve dividing the problem into smaller, solvable parts and using numerical methods to find solutions.

5. Is it necessary to have a strong background in physics to use Matlab for solving electric and magnetic fields?

While having a basic understanding of physics concepts is helpful, it is not necessary to have a strong background in physics to use Matlab for solving electric and magnetic fields. The software provides built-in functions and tools that make it accessible to users with varying levels of knowledge and experience in physics.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
535
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
311
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
19
Views
452
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
Back
Top