Is it possible to make a plot with three variables, but using only ta 2-D plot? For instance, I want the x-axis to be time, y-axis to be height, and the independent variable to be temperature. I haven't found anything online that would hint at a possibility, but thought it wouldn't hurt to ask. Thanks!

 Respuesta aceptada

ANKUR KUMAR
ANKUR KUMAR el 27 de Dic. de 2017

1 voto

If you want to use 3 variables on 2D plot, then you can use contour or contourf or surf or surfc.
clc
clear
lat=(1:10)';
lon=(1:20)';
rf=randi(20,10,20);
figure()
contourf(lon,lat,rf,'linecolor','none');
figure()
[x,y]=meshgrid(lon,lat);
a=surf(x,y,rf,'FaceAlpha',0.5,'EdgeColor', 'none')
figure()
surfc(x,y,rf,'FaceAlpha',0.5,'EdgeColor', 'none')

5 comentarios

Wafa'a Shanti
Wafa'a Shanti el 29 de Dic. de 2017
Thank you for this. Now when using imported data, I created arrays for each of the variables: timearray, z, Temp. I put these variables into a contourf plot,
contourf(timearray1,z1, Temp1)
and the error received is:
Input arguments must be numeric or objects which can be converted to double.
Each variable is a list of numeric values, so the error lies in the object possessing the ability to convert to a double. What does that mean exactly?
ANKUR KUMAR
ANKUR KUMAR el 30 de Dic. de 2017
If you have created array, then use
contourf(timearray1{1},z1{1}, Temp1{1})
Wafa'a Shanti
Wafa'a Shanti el 30 de Dic. de 2017
Cell contents reference from a non-cell array
This is what I receive when I do this. I have used table2array function to convert each column in the data table imported to an array. I tried to use (1) instead, and received the same error message as before (which after reading online, makes sense why it would produce such error).
ANKUR KUMAR
ANKUR KUMAR el 30 de Dic. de 2017
Editada: ANKUR KUMAR el 30 de Dic. de 2017
If your problem is not resolved yet, then please provide your program, so that we can help you.
Wafa'a Shanti
Wafa'a Shanti el 30 de Dic. de 2017
As a forewarning, there are two different sets of data from two different schools. Each one has about 25 tables I had to import and convert to arrays, which was done by simply changing the number located next to the variables.
First set of data:
datapath1='C:\Users\Faye\Documents\MATLAB\xq_directDownWashf12.csv';
formatspec='%f%f%f%f%f%f%{MM-dd-yyyy HH:mm:ss}D%{MM-dd-yyyy HH:mm:ss.SSSSSS}D';
NumericValueTable1=readtable(datapath1,'Delimiter',',','HeaderLines',0,'Format',formatspec);
Pulldataout1=NumericValueTable1(:,1:6);
UASdata1=table2array(Pulldataout1);
timearray1=table2array(NumericValueTable1(:,7));
Temp1=table2array(NumericValueTable1(:,2));
z1=table2array(NumericValueTable1(:,4));
second set of data:
datapath1='C:\Users\Faye\Documents\MATLAB\OSUr1.csv';
NumericValueTable1=readtable(datapath1);
pulloutdata1=NumericValueTable1(:,[2 1]);
OSUdata1=table2array(NumericValueTable1(:,[3 2]));
data1=num2str(OSUdata1);
OSUd1=datetime(data1,'Inputformat','yyyyMMdd HHmmss');
OSUd1=datestr(OSUd1);
NumericValueTable1.class=OSUd1;
writetable(NumericValueTable1,'OSUr1.csv','Delimiter',',','Quotestrings',false);
datapat1='C:\Users\Faye\Documents\MATLAB\OSUr1.csv';
NumericValueTable1=readtable(datapat1);
Newdata1=NumericValueTable1(:,(3:9));
OSUdata1=table2array(pulloutdata1);
timearray1o=table2array(NumericValueTable1(:,1));
Temp1o=table2array(NumericValueTable1(:,8));
Tempp1=Temp1o/100;
z1o=table2array(NumericValueTable1(:,6));
zo1=z1o/100;
The goal is to contour, like stated before, the time, height (z), and temp/tempp

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Line Plots en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 27 de Dic. de 2017

Comentada:

el 30 de Dic. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by