필터 지우기
필터 지우기

create a vector field of Ex and Ey

조회 수: 7 (최근 30일)
Munawar Karim
Munawar Karim 2024년 3월 26일
댓글: Munawar Karim 2024년 6월 11일
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
John D'Errico
John D'Errico 2024년 3월 26일
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 2024년 5월 3일
Thank you - I will follow your advice.

댓글을 달려면 로그인하십시오.

답변 (1개)

Nivedita
Nivedita 2024년 5월 3일
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
Munawar Karim
Munawar Karim 2024년 5월 3일
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 2024년 6월 11일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Graphics Objects에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by