Surface plot missing a final array element for discrete values

조회 수: 11 (최근 30일)
Alexander Sholtz
Alexander Sholtz 2021년 1월 21일
댓글: Cris LaPierre 2021년 1월 21일
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
Cris LaPierre
Cris LaPierre 2021년 1월 21일
Share your variable tempValues. Save it to a mat file and attach it to your post using the paperclip icon.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Map Display에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by