Connecting Dots in a plot

5 次查看(过去 30 天)
Marcelo Boldt
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