Borrar filtros
Borrar filtros

Color-coding a 2D plot

5 visualizaciones (últimos 30 días)
Joana Silva
Joana Silva el 18 de Jul. de 2018
Editada: Joana Silva el 19 de Jul. de 2018
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 comentarios
jonas
jonas el 18 de Jul. de 2018
Upload the data, not the code. Also, don't upload code as images...
Joana Silva
Joana Silva el 18 de Jul. de 2018
It's this.

Iniciar sesión para comentar.

Respuesta aceptada

jonas
jonas el 18 de Jul. de 2018
Editada: jonas el 18 de Jul. de 2018
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 comentarios
jonas
jonas el 19 de Jul. de 2018
' 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 el 19 de Jul. de 2018
Editada: Joana Silva el 19 de Jul. de 2018
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Visual Exploration en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by