Effacer les filtres
Effacer les filtres

create a vector field of Ex and Ey

3 vues (au cours des 30 derniers jours)
Munawar Karim
Munawar Karim le 26 Mar 2024
Commenté : Munawar Karim le 11 Juin 2024
Hello: I am trying to create a vector field graph with given values of Ex and Ey for a range of values of 'r' and 'theta'. I have the values of 'r' and 'theta'' on an excel sheet.
Can someone help me read and enter the data ponts in a Matlab program?
Much appreciate your advice. I am completley new to Matlab.
Kind regards
M K
  2 commentaires
John D'Errico
John D'Errico le 26 Mar 2024
You need to do the MATLAB Onramp. Start by learning MATLAB.
If you want to read in data from a spreadsheet, then you would start by reading the help docs for readtable. (readtable)
As far as the graph you want to form, you have not even said enough to know what you need to do.
Munawar Karim
Munawar Karim le 3 Mai 2024
Thank you - I will follow your advice.

Connectez-vous pour commenter.

Réponses (1)

Nivedita
Nivedita le 3 Mai 2024
Hello Munawar,
To create the vector field graph, you can follow these steps:
  1. Assuming your Excel file has two columns where the first column is 'r' and the second column is 'theta', and the file is named "data.xlsx", you can read the data using the "readmatrix" function. You can replace "data.xlsx" with your filename.
  2. Assuming you have equations to calculate Ex and Ey based on r and theta, you can proceed to calculate these. If you do not have specific equations, you'll need to provide them. I have used example equation in the below code.
  3. MATLAB's "quiver" function is used to create vector field graphs. You'll need to convert your polar coordinates ('r' and 'theta') to Cartesian coordinates (x and y) to use with "quiver".
% Step 1: Read data from Excel
[r, theta] = readmatrix('data.xlsx'); % Adjust this line accordingly if using xlsread
% Step 2: Calculate Ex and Ey (replace with your equations)
Ex = r .* cos(theta);
Ey = r .* sin(theta);
% Step 3: Convert polar to Cartesian coordinates for plotting
x = r .* cos(theta);
y = r .* sin(theta);
% Step 4: Create the vector field graph
quiver(x, y, Ex, Ey);
xlabel('X');
ylabel('Y');
title('Vector Field of Ex and Ey');
axis equal;
For more information on the "quiver" function, refer the following documentation link:
I hope this example helps you.
  2 commentaires
Munawar Karim
Munawar Karim le 3 Mai 2024
Hello
Many, many thanks for the trouble you have taken to respond to my plea.
I have all the figures you have advised me to collect.
Since the range of values is huge I will have to take the log-log to make the numbers fit the graph.
I will follow your suggestions. Since I am totally new to Matlab it will take time.
I will let you know how it turns out.
Once again - thanks.
Munawar Karim
Munawar Karim le 11 Juin 2024
Hello
Further to my previous question:
The equations for E_x and E_y are very elaborate.
Instead of using MATLAB to calculate these two quantities I have used Excel to do the calculation.
I have arrays for 'r', 'theta', E_r, and E-theta, as well as E_x and E_y. They are in Excel.
I have theta is degrees as well as radians.
Can you guide me to steps I need to take to enter the values?
I am slowly getting there.
Much appreciate your help.

Connectez-vous pour commenter.

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by