필터 지우기
필터 지우기

Color-coding a 2D plot

조회 수: 4 (최근 30일)
Joana Silva
Joana Silva 2018년 7월 18일
편집: Joana Silva 2018년 7월 19일
Hi everyone! I want to make a nice colour graph with my data but I don't know exactly what I'm looking for. So in my experiment, I measured the excess pore pressure in 12 different positions in a deposit of sand (40x40cm side view). I have an example of the results I have for the transducers 9, 10, 11 and 12 (Fig.1). What I want is an easy way to visualise this changes in pressure in all transducers at once through time. For example, a square 40x40cm and the changes in colour (pressure) for each transducer area for the first 2 minutes (Fig.2). I know the exact position of each transducer: 12cm between them and 2cm from the top/bottom. Basically I want 2min "video" to see which part of the sand deposit is contracting or dilating during the experiment. I'm new in MatLab. I only know the basic codes to analyse my data. But now I have other ideas to present this data. Can you help me please? Thanks! Joana
  댓글 수: 4
jonas
jonas 2018년 7월 18일
Upload the data, not the code. Also, don't upload code as images...
Joana Silva
Joana Silva 2018년 7월 18일
It's this.

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

채택된 답변

jonas
jonas 2018년 7월 18일
편집: jonas 2018년 7월 18일
The simplest way to create an animation is to first create a plot and then update the 'XData', 'YData' and 'ZData' properties (or in this case just the 'ZData'). You can spend days adjusting the visuals. This code provides the basics for plotting values over time in a 4x3 grid. I hope this is somewhat what you had in mind. Happy to help further if it's not.
Note: You did not give me the variable S, so I could not adjust the data accordingly. I just used the data you gave me.
DenseSand = fileread('D.Test.lvm');
Densesant = strrep(DenseSand,',','.');
DenseSand = str2num(DenseSand);
%%Data
Num_Samples2 = [1:1:size(DenseSand,1)]';
MeasFr = 200;
Time2 = Num_Samples2 / MeasFr;
T=DenseSand.*0.1;
z=T(:,[4 5 9 2 6 10 3 7 11 4 8 12]);
%%Coordinates
x=repmat(2:12:26,1,4);
y=repmat(2:12:38,3,1);
y=y(:);x=x(:);
%%Create finer mesh
[Xq,Yq]=meshgrid(0:1:40,0:1:40);
%%Plot
h=surf(Xq,Yq,zeros(size(Xq)));
set(gca,'ZLim',[0 1e5])
colormap('jet')
view(2)
%%Interpolate and plot each frame
for i=1:length(Time2)
h.ZData=griddata(x,y,z(i,:)',Xq,Yq,'nearest');
drawnow
title(['Time: ',num2str(Time2(i))])
end
This code takes more than 2 minutes to run on my machine. It's easy to increase the time between animations by inserting a pause, however the minimum time can only be changed by making the code more efficient. You can however increase the amount of frames by not plotting every value, simply change the iterations to
i:step:length(Time2)
  댓글 수: 2
jonas
jonas 2018년 7월 19일
' what variable S? '
In your image you subtract some mean of a variable S from T. But the code does not show what S is.
Joana Silva
Joana Silva 2018년 7월 19일
편집: Joana Silva 2018년 7월 19일
Ah, yes. Well the variable S it doesn't matter. It is just to subtract the additional pressure from the deposition of the sand in the flume to make sure that all transducers start measuring from zero.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Visual Exploration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by