Please urgently if possible I need to solve the following problem
An equation give me graph of some layers at depths z1, z2, z3, and z4 (see attached figure), and I need to break them down (vertical offset) with a constant = z2-z1= z3-z2=z4-z3 (if satisfying this condition), in addition to drowing a vertical line (red line in satisfied location)

 採用された回答

Star Strider
Star Strider 2022 年 9 月 30 日

0 投票

Try something like this —
zv = sort(rand(4,1)) % Define 'z' Values
zv = 4×1
0.0231 0.1089 0.3493 0.7581
const = rand % Define Constant Offset
const = 0.0537
figure
plot([0 1], zv*[1 1], '-k', 'LineWidth',1.5)
hold on
plot([1 2], (zv-const)*[1 1], '-k', 'LineWidth',1.5)
hold off
xline(1, '-r', 'LineWidth',2)
linelabels = compose('z%d',numel(zv):-1:1);
text(zeros(size(zv)), zv, linelabels, 'Horiz','left', 'Vert','bottom')
text(zeros(size(zv))+2, zv-const, linelabels, 'Horiz','right', 'Vert','bottom')
set(gca, 'Visible','off') % Hide Axes (Optional)
Define the the ‘zv’ vector as a column vector of increasing values, and define the constant (‘const’) as a single scalar.
.

4 件のコメント

Moustafa Abedel Fattah
Moustafa Abedel Fattah 2022 年 9 月 30 日
Thank you Star Strider
it is working but my Matlab version R2014b (old version) so, the command xline is not defined
Star Strider
Star Strider 2022 年 9 月 30 日
As always, my pleasure!
Instead of xline then, try this slightly edited version —
zv = sort(rand(4,1)) % Define 'z' Values
zv = 4×1
0.1188 0.4990 0.6504 0.9499
const = rand % Define Constant Offset
const = 0.1647
figure
plot([0 1], zv*[1 1], '-k', 'LineWidth',1.5)
hold on
plot([1 2], (zv-const)*[1 1], '-k', 'LineWidth',1.5)
plot([1 1], ylim, '-r', 'LineWidth',2) % Work-Around For 'xline'
hold off
linelabels = compose('z%d',numel(zv):-1:1);
text(zeros(size(zv)), zv, linelabels, 'Horiz','left', 'Vert','bottom')
text(zeros(size(zv))+2, zv-const, linelabels, 'Horiz','right', 'Vert','bottom')
set(gca, 'Visible','off') % Hide Axes (Optional)
Everything else should work as written. If not, let me know and I will do what I can to solve whatever problems remain.
.
Moustafa Abedel Fattah
Moustafa Abedel Fattah 2022 年 9 月 30 日
Thank you Star Strider for your always quick response ... well done
Star Strider
Star Strider 2022 年 9 月 30 日
As always, my pleasure!

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2022 年 9 月 30 日

0 投票

Try xline and yline. You can use the 'LineWidth' and 'Color' option to set up the line thickness and color.

2 件のコメント

Moustafa Abedel Fattah
Moustafa Abedel Fattah 2022 年 9 月 30 日
What about the vetical offset?
Image Analyst
Image Analyst 2022 年 9 月 30 日
If the line is not going all the way across the graph, you can use line or plot() to specify the endpoints at whatever x and y values you want, so you'll get line segments.

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

カテゴリ

ヘルプ センター および File Exchange で MATLAB Mobile Fundamentals についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by