How to I read excel file and create a 3d plot?

12 views (last 30 days)
I am trying to read data from an excel file and create a 3D plot. In the excel file the first row is different temperatures used, the first column is the frequencies that were used. The values starting from the second row and second column represent a specific value. Each sample value is assciated with a specific temeparture and frequency. For instance the measurements for a sample at 160 degrees for a 22 Hz frequency is 16.8. I am having an issue making sure that the corresponding temperatures and frequencies have the correct values associated with the certain values. In my code I am able to read and create a variable for temperatures and frequencies but I do not see the value associated with a specific temperature and frequency.
For the plot I want to be able to have a 3D plot in which if I go to a specific temperature and frequency value I would be able to see a specific value associate with. My current code shows the temperatures and frequencies but I do not think it has the corresponding sample values. For example if I were to plot my data in a 3D plot it appears to only show values for a frequency of 0 Hz. Also if possible is there a way to get rid of the colors in the 3D plot.
T1 = readtable('Epsilon_Prime.xlsx');
T1.Var2 = str2double(T1.Var2);
x = T1{1,2:end};
y = T1{2:end,1};
z = fillmissing(T1{2:end,2:end}, 'nearest'); % Interpolate 'NaN' Elements
mesh(x, y, z)
xlabel('Temp (C)')
ylabel('Freq (Hz)')
zlabel('Epsilon')
% Issue: It looks that not every epsilon is represented in my plot

Answers (1)

Voss
Voss on 17 Jul 2023
The plot seems accurate. Take a look at the first row of Epsilons in the file (i.e., corresponding to 20Hz). They are orders of magnitude larger than the Epsilon values further down in the table (i.e., at higher frequencies).
Maybe it's better to show them on a logarithmic scale. See below for that, and also using a single-color mesh (in this case blue, but you can set it to something else) to get rid of the colors.
T1 = readtable('Epsilon_Prime.xlsx');
T1.Var2 = str2double(T1.Var2);
x = T1{1,2:end};
y = T1{2:end,1};
z = T1{2:end,2:end};
mesh(x, y, z, 'EdgeColor', 'b');
xlabel('Temp (C)')
ylabel('Freq (Hz)')
zlabel('Epsilon')
set(gca(),'ZScale','log')

Categories

Find more on Image Data Workflows in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!