Import values having different units in matlab

1 view (last 30 days)
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

Answers (1)

Mrinal Anand
Mrinal Anand on 8 Jul 2023
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.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!