How to plot z (data) on x-y (grid) from a structure?
古いコメントを表示
Hi! I state that I'm a beginner on Matlab and this is just my second interaction on the community, so I apologize if my code seems stupid. It WORKS, but I have a problem regarding a plot. I have a structure (file.mat, attached) where 5 simulations of wave energy transport happen on a grid (195x336 cells). Every result is stored on a field, for a total of 5x195x336 data. Since each simulation occur for a certain time (array "CumHours"), I was able to multiply each of the 5 simulations for the proper time (for cycle). Then I summed all the result ("TOT") and divided by the sum of the hours, in order to get a weighted average of the energy transport on the grid.
clear all
close all
TotalData = load('Etransp_5steps.mat');
Dati=TotalData.data;
Values=Dati.Val %to see how the results are organized
plot(extractfield(Dati,'X'),extractfield(Dati,'Y')); %image of the grid
Extract=extractfield(Dati,'Val');
%%
CumHours=[0.3; 3.03; 14.56; 3.34; 0.3;]; %5 amount of hours for every simulation
sumCH=sum(CumHours(:));
s=1;
f=5;
for cont=1:f
NewVal(s,:,:)=Values(s,:,:)*CumHours(s,1);
s=1+s;
end
%%
j=1;
Cum=NewVal(j,:,:);
while j<f
j=j+1;
Cum=Cum+NewVal(j,:,:);
end
TOT=Cum;
ResultVal=TOT(1,:,:)/sumCH;
figure(1);
s=plot3(Dati.X(2:end,2:end),Dati.Y(2:end,2:end),squeeze(ResultVal(1,:,:)));
figure(2);
t=scatter3(Dati.X(2:end,2:end),Dati.Y(2:end,2:end),squeeze(ResultVal(1,:,:)));
The problem is on the plot; by previous suggestions I used plot3 to get the results, but what I would like to get is the grid, on which I plot "ResultVal" with a jet colormap. In order to get an idea, this is the goal

But of course, by using plot3, I get this, which is correct but not my idea.

Can someone help me to understand what should I use? Maybe playing with the properties?
Thanks a lot.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Interpolation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

