ํ•„ํ„ฐ ์ง€์šฐ๊ธฐ
ํ•„ํ„ฐ ์ง€์šฐ๊ธฐ

how to add 2nd y-axis on give graph?

์กฐํšŒ ์ˆ˜: 2 (์ตœ๊ทผ 30์ผ)
dharmin
dharmin 2023๋…„ 7์›” 8์ผ
์ด๋™: Matt J 2023๋…„ 7์›” 8์ผ
Dear community, I have written a basic code to plot the results of my findings, but I am struggling to add a second y-axis to the plot. Could anyone please help me with this small issue? Thank you! ๐Ÿ˜Š The second axis should display the values of L. Here, z represents the coordinates of each ply, starting from 0 at the center and extending symmetrically in both directions.
sigma_x = X(1, :);
sigma_y = X(2, :);
tau_12 = X(3, :);
L1 = [zeros(1, l),90*ones(1,m)];
L = [L1,fliplr(L1)];
z =nonzeros(z)';
% Plot sigma_x versus z
plot(sigma_x, z, 'DisplayName', '\sigma_x','LineStyle','-','LineWidth',2);
hold on;
% Plot sigma_y versus z
plot(sigma_y, z, 'DisplayName', '\sigma_y','LineStyle','-','LineWidth',2);
% Plot tau_12 versus z
plot(tau_12, z, 'DisplayName', '\tau_{12}','LineStyle','-','LineWidth',2);
xlabel('Stress (MPa)');
ylabel('z (m)');
%xlim([-5e8 5e8]);
% Add legend
legend('Location', 'best','FontSize',12);
% Set limits for y-axis
ylim([min(z) max(z)]);
title("[0_{m}/90_{n}]_{s}")
on this graph I want value of L on right hand side.
  ๋Œ“๊ธ€ ์ˆ˜: 2
Dyuman Joshi
Dyuman Joshi 2023๋…„ 7์›” 8์ผ
Do you mean something like this - yyaxis ?
If not, then please specify the desired output.
dharmin
dharmin 2023๋…„ 7์›” 8์ผ
yes yyaxis, where value on Right hand side y-axis is taken from variable L which is storing the orientation data of each ply.

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.

์ฑ„ํƒ๋œ ๋‹ต๋ณ€

Star Strider
Star Strider 2023๋…„ 7์›” 8์ผ
์ด๋™: Matt J 2023๋…„ 7์›” 8์ผ
See the documentation for yyaxis. It should be all you need.

์ถ”๊ฐ€ ๋‹ต๋ณ€ (0๊ฐœ)

์นดํ…Œ๊ณ ๋ฆฌ

Help Center ๋ฐ File Exchange์—์„œ 2-D and 3-D Plots์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณด๊ธฐ

์ œํ’ˆ


๋ฆด๋ฆฌ์Šค

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by