Import values having different units in matlab

2 次查看(过去 30 天)
Dear sir,
I have three parameters Ez, Bx and By with some finite values of each of them.
Ez is in "mm" while Bx and By are in "degree".
I want to plot volume plot between them as a 3-D plot. (though they have different units)
I am using the following code for that and getting a 3-D plot:
T = readtable('New12.xlsx', 'Sheet',1, 'Range','A2:C35');
T = table2array(T);
Ez=T(:,1);
Bx=T(:,2);
By=T(:,3);
plot3(Ez,Bx,By,'.');
kkk=boundary(Bx,By,Ez);
trisurf(kkk,Bx,By,Ez,'Facecolor','r');
xlabel('Bx(deg)');
ylabel('By(deg)');
zlabel('Ez(mm)');
Now, my concern is : Ez is in 'mm ' and Bx and By are in degree, but the plot I am getting will be in cartesian cordinate..? (Sorry, I am not aware but my anticipation is that the Matlab uses cartesian coordinate system to plot, until unless specified).
The values of Bx and By are in degrees but how does this code will know that they are in degrees? It might considering their values in "mm" only if MATLAB uses cartesian coordinate system.
So, please let me know how to make understand the code that two values are in degrees and one in mm? or how to import the degree values in matlab? (since I am directly importing them just like Ez which is in mm).
Please resolve my issue.
An excel file is attached here for the reference.
Thanks and regards,
Anshul Jain

回答(1 个)

Mrinal Anand
Mrinal Anand 2023-7-8
Matlab plotting functions assume that the plotting data is given in Cartesian coordinates by default. So you need to convert your angle data to Radians before plotting. Here are the modifications you should make to your code:
Bx_rad = deg2rad(Bx_deg);
By_rad = deg2rad(By_deg);
Your code should then plot the correct figure.

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by