Surface plot missing a final array element for discrete values

5 views (last 30 days)
Hi,
I have a string of temperature sensors and I am trying to plot an array of their values over time. To do this I am organizing the values into a 2D m by n array "tempValues" where column 1 corresponds to the first sensor, column 2 the second, so on and so forth. I then have 2 separate 1D arrays "sensorNum" of length n and "sampleNum" of length m. When I try to make a surface plot of the values though it is dropping the last sensor. Here you can see a plot of a 7-sensor string plotted this way. I think this is happening because MatLab is not treating the values of "sensorNum" as discrete, but I'm not sure. How can I fix this to get a surface plot of all of my sensors?
Code used to generate plot:
%% plot surface plot of all temperature sensor array (proof of concept)
%calculate sample number and sensor number and create an array of
%temperatures from a table of temperature sensor values
%assign variables
tempValues = table2array(string6Table);
string = "String 6";
[m, n] = size(tempValues);
sampleNum = 1:m;
sensorNum = 1:n;
figure()
clf
s=surf(sampleNum, sensorNum, tempValues', 'CDataMapping', 'scaled');
s.EdgeColor = 'none';
view(0,270) % 2D x=1:sampleNum, y=sensor number 1 at top. Baseline "normal" view
xlabel('Sample Number')
ylabel('Sensor Number')
title(sprintf('Surface Plot of Temperature vs. Time for %s', string));
  1 Comment
Cris LaPierre
Cris LaPierre on 21 Jan 2021
Share your variable tempValues. Save it to a mat file and attach it to your post using the paperclip icon.

Sign in to comment.

Answers (0)

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!