How to create a vertical offset line
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Moustafa Abedel Fattah
le 30 Sep 2022
Commenté : Image Analyst
le 30 Sep 2022
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)![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1141385/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1141385/image.jpeg)
0 commentaires
Réponse acceptée
Star Strider
le 30 Sep 2022
Try something like this —
zv = sort(rand(4,1)) % Define 'z' Values
const = rand % Define Constant Offset
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 commentaires
Plus de réponses (1)
Image Analyst
le 30 Sep 2022
2 commentaires
Image Analyst
le 30 Sep 2022
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.
Voir également
Catégories
En savoir plus sur Standard File Formats dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!