0
%Sampling Frequency
f=8000;

%Sampling Time
t=5;
%Data imported from microsoft Excel
matrix=Book2S1;

%Size Matrix
s=size(matrix);
h=s(1,1);
w=s(1,2);

%Set Up Rows and Columns
rows=(0:(f/2)/(h-1):f/2);
columns=(0:t/(w-1):t);

%plot
mesh(columns,rows,matrix);
xlabel('Time, s')
ylabel('Frequency, Hz')
zlabel('Power Spectral Density, V^2/Hz')`enter code here

This is the code that I type in to attempt to get a 3D plot. The goal is for me to obtain a plot that looks like the image listed below, but I continue getting a mesh error

Error using mesh (line 139) Data inputs must be numeric, datetime, duration, categorical arrays or objects which can be converted to double.

Error in Lab_3_1 (line 21) mesh(columns,rows,matrix);

What my plot is supposed to look like. The picture didn't want to get saved after being cropped, sorry people.

The following is a link to half of the data being used for this plot. https://docs.google.com/spreadsheets/d/e/2PACX-1vRMWfmFYDnwMSPzahD8k-aWAXHstbNRdlY4gmOHJoXkLaBb4PY7zF5-41yFkQHR4g0w3LrMFiz3ZqWJ/pubhtml

2 Answers2

0

Try substituting your 4049x50 matrix replacing my random matrix f:

% t=5;
% fs = 8000;
lower = -60;
upper = 20;
f = (upper-lower).*rand(4049,50) + lower;
% s=size(f);
% h=s(1,1);
% w=s(1,2);
% rows=(0:(fs/2)/(h-1):fs/2);
% columns=(0:t/(w-1):t);
mesh(f);
colormap('jet');
colorbar;
xlabel('Time, s')
ylabel('Frequency, Hz')
zlabel('Power Spectral Density V^2/Hz')
ylim([0 4000])
zlim([-100 40])

Using the random data matrix f, I get this:

3D plot

Louis Leung
  • 508
  • 4
  • 11
0

I figured out that the values that were imported into MATLAB were converted into string values. I stopped using the import button and used the xlsread function instead, and that allowed me to import the numerical values without them being converted into strings.

Finished Code

Resulting 3D Plot

Thank you guys for the help and looking over the problem.