Plot velocity profiles along a slope

3 ビュー (過去 30 日間)
Nhat
Nhat 2024 年 3 月 10 日
コメント済み: Mathieu NOE 2024 年 3 月 25 日
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 件のコメント
Mathieu NOE
Mathieu NOE 2024 年 3 月 11 日
plotting the data in itself is not complicated
the ruler may require a bit more work , depends how sophisticted you want to have it

サインインしてコメントする。

回答 (1 件)

Mathieu NOE
Mathieu NOE 2024 年 3 月 11 日
編集済み: Mathieu NOE 2024 年 3 月 11 日
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 件のコメント
Mathieu NOE
Mathieu NOE 2024 年 3 月 13 日
Yes, some adaptation to your needs may be required
Mathieu NOE
Mathieu NOE 2024 年 3 月 25 日
do you mind acepting my answer ? tx !

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeFormatting and Annotation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by