필터 지우기
필터 지우기

Connecting Dots in a plot

조회 수: 2 (최근 30일)
Marcelo Boldt
Marcelo Boldt 2020년 7월 16일
댓글: Marcelo Boldt 2020년 7월 16일
Hello everyone!
I have 1 Vector (8x1 dimension) and 1 Array (3x1x8 dimension) and I want to connect each number of the vector with first element of each vector that belong to the array (this would mean 1x1x8)
My script works but I am struggling to connect the each point with a line, Can you help me ?
Here is my extract of code:
for i = 1:Nplies
zbar(i,1) = -(h + t)/2 + i*t;
theta = thetadb(i) * pi / 180;% ply i angle in radians, from bottom
theta_global(i,1) = thetadb(i);
c = cos(theta);
s = sin(theta);
T = [ c^2 s^2 -2*c*s; s^2 c^2 2*c*s; c*s -c*s (c^2 - s^2)];
T_inv = [c^2 s^2 c*s; s^2 c^2 -c*s; -2*c*s 2*c*s (c^2 - s^2)];
Qbar = T * Q * T_inv; %transformed reduced stiffness matrix
NT(:,:,i) = NTi + Qbar * abar * t * deltaT;
NT_plot(:,:,i) = NTi + Qbar * abar * t * deltaT;
figure(2)
plot (NT_plot(1,:,i),zbar(i,1),'dr')
xlabel('Loads in X')
ylabel ('Laminate Global Thickness [mm]')
legend ('NT across the Laminate')
hold on
grid on
line(NT_plot(1,:,i),zbar(i,1))
end
  댓글 수: 4
Arthur Roué
Arthur Roué 2020년 7월 16일
편집: Arthur Roué 2020년 7월 16일
Yeah, matrix NT_plot has 3 dimension and plot function is for 2-D line plot.
I don't really understand your context, and I dont have your data. Try to plot in a loop, something like :
for dim = 1:size(NT_plot,3)
plot (NT_plot(1,:,dim), zbar(:,1), 'LineStyle', '-', 'DisplayName', num2str(dim))
end
or a 3D plot with : plot3, mesh, ...
Marcelo Boldt
Marcelo Boldt 2020년 7월 16일
I could make it work! Thanks for your help, was very useful

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by