My line plot doens't work according to plot([x1 x2], [y1,y2])
Show older comments
I've been staring at it for a while now, but i want to make horizontal, vertical and both diagonal elements in my window,
Elem is the connection matrix, providing information about what nodes to couple. Then XY_plot is are respectively the x-value of node 1, the x-value of node 2, the y-value of node 1 and the y-value of node 2.
XY_plot = zeros(length(Elem),4);
for i = 1:length(Elem)
node_1 = Elem(i,1);
node_2 = Elem(i,2);
XY_1 = nodes(node_1,:);
XY_2 = nodes(node_2,:);
XY_plot(i,:) = [XY_1(1) XY_2(1) XY_1(2) XY_2(2)];
end
X_val = [XY_plot(:,1) XY_plot(:,2)];
Y_val = [XY_plot(:,3) XY_plot(:,4)];
%
clf, figure(1), subplot(1,2,1), hold on,
plot(X_val,Y_val,'k-')
plot(xpos,ypos,'o','MarkerFaceColor', 'y')
hold off
But this doesn't work, however the plot(X_val, Y_val) satisfies the plot([x1 x2] , [y1 y2]). Does anyone see why it doesn't work?
I attached the Elem and nodes files.
Accepted Answer
More Answers (0)
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!