Effacer les filtres
Effacer les filtres

How can I plot three columns of a dataset to produce an image or a map?

4 vues (au cours des 30 derniers jours)
I have the randomly generated data with the final dataset in the Variable 'DATA'
===========================================
D = [66;67;68;69;70;74;75;76;78;83];
Day =repelem(D,11);
timeH = (13:23)'; timeH = repmat(timeH,[10,1]);
xmin=0;
xmax=0.9;
n=110;
x = xmin+rand(1,n)*(xmax-xmin);
x = x';
DATA = [Day,timeH,x];
===========================================
I want to produce an image or map with x-axis Day, y-axis as timeH and z-axis as x.
I have tried with:
imagesc(Day,timeH, x)
but the output I'm getting is more of stripped color lines,
I want a map like the images attached (days on the x axis instead)
or
I would be grateful if i can get help. Thank you

Réponse acceptée

Joe Vinciguerra
Joe Vinciguerra le 24 Mar 2023
The data needs to be reshaped.
Here are a few different plotting options, depending no how you went to represent the data.
D = [66;67;68;69;70;74;75;76;78;83];
Day =repelem(D,11);
timeH = (13:23)'; timeH = repmat(timeH,[10,1]);
xmin=0;
xmax=0.9;
n=110;
x = xmin+rand(1,n)*(xmax-xmin);
x = x';
DATA = [Day, timeH, x];
% Reshape the data into matrices
d = reshape(DATA(:,1), [11, 10]);
t = reshape(DATA(:,2), [11, 10]);
X = reshape(DATA(:,3), [11, 10]);
% plot as a scaled color image
imagesc(Day, timeH, X)
colorbar()
% plot as a scaled color image with interpolated visualization
imagesc(Day, timeH, X, "Interpolation", "bilinear")
colorbar()
% plot as a filled contour map
contourf(d, t, X, "LineStyle","none")
colorbar()
% plot as a 3D surface, viewed from top with interpolated shadind
surf(d, t, X, "LineStyle","none")
shading(gca, "interp")
colorbar()
view(0, 90)
axis tight
  3 commentaires
Joe Vinciguerra
Joe Vinciguerra le 24 Mar 2023
If I understand you, something like xticks(66:83) or xticks(D).

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by