Plot velocity profiles along a slope
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi everyone,
I'm seeking assistance with plotting velocity profiles at multiple cross-sections on a single graph and incorporating a ruler.
Any suggestions or ideas to tackle this challenge would be greatly appreciated.
Thank you!

1 comentario
Mathieu NOE
el 11 de Mzo. de 2024
plotting the data in itself is not complicated
the ruler may require a bit more work , depends how sophisticted you want to have it
Respuestas (1)
Mathieu NOE
el 11 de Mzo. de 2024
Editada: Mathieu NOE
el 11 de Mzo. de 2024
hello again
so this is a starter , would need further work to define correct range of the ruler according to your data
%% create some dummy data
x = (1:100);
ytop = 10 + 3*exp(-x/100); % top envelope curve
ybottom = 3 - 2*exp(-x/100); % bottom envelope curve
% main plot
plot(x,ytop,'k--',x,ybottom,'k-','linewidth',1.5);
ylim([0 max(ytop)+3]);
hold on
% plot "red" data at xpos1 = 25.8; % or whatever number you want
xpos1 = 25.8;
xd1 = (1:40); % local x vector (rotated 90°)
yd1 = -5*exp(-(xd1-5).^2); % local y vector (rotated 90°)
% map the xd1 range between top and bottom lines
ytop1 = interp1(x,ytop,xpos1);
ybottom1 = interp1(x,ybottom,xpos1);
xd1_mapped = linspace(ybottom1,ytop1,numel(xd1));
plot(xpos1*ones(size(xd1_mapped)),xd1_mapped,'b','linewidth',0.5); % plot the reference baseline (local y = 0)
plot(xpos1 + yd1,xd1_mapped,'r--'); % plot the data
%% Ruler
nrTicks = 9; % must be odd number !!
% Minimum and maximum values as integers for the generation of the ruler
xMin = -(nrTicks-1)/2;
xMax = -xMin;
markerXpos = xMin:xMax;
scale_factor = 1;
%
width = 2;
TickLengthMajor = width / 5;
TickLengthMinor = TickLengthMajor/2;
textOffset = 0.3;
%
% Plot the x axis
plot( [xMin xMax]*scale_factor+xpos1, [0 0]+xd1_mapped(1), 'k','linewidth',width);
% Plot end (major) ticks
for k=[1 (nrTicks+1)/2 nrTicks]
at = markerXpos( k );
bt = at*scale_factor+xpos1;
plot( [bt, bt], [0, TickLengthMajor]+xd1_mapped(1), 'k');
text( bt, - textOffset + xd1_mapped(1),...
int2str(markerXpos(k)),...
'HorizontalAlignment', 'Center');
end
% Plot in between (minor) ticks
for k=2:nrTicks-1
at = markerXpos( k );
bt = at*scale_factor+xpos1;
plot( [bt, bt], [0, TickLengthMinor]+xd1_mapped(1), 'k');
end
hold off
6 comentarios
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

