How can I plot different lines of a loop in different graphs, each one including all the solutions from a previous loop??
8 views (last 30 days)
Show older comments
Hello!
This is the problem I have with my code: the first graph plots the number of tiles I imput minus one (let's call it the main body of tiles), and the second graph plots that remaining tile in the different positions sourrounding the main body in the first loop. What I need to do is create the same number of graphs as possibilities of the remaining tile, and in each graph I need to plot the main body plus one of the posibilities. Can it be done? Thank you in advance!
bx=5 %Dimension of each sides of the square
cy=10
ntiles=3 %Number of squares
nt=ntiles-1 %I take out one tile to get rid of the 0
b=bx/2 %I divide the dimensions by two so I can center the squares around the (0,0) coordinates with positive and negative values
c=cy/2
x=[b b -b -b b]
y=[-c c c -c -c]
ntt=nt-1 % I get rid of that tile that has multiple possibilities
horizontal=-(ntt/2):(ntt/2) %I create a scalar that symbolises each square, and apply to this the dimensions of the square
horizontal=(horizontal*bx)'
xcoordinates=(horizontal+x)'
[m,n]=size(xcoordinates)
vectorn=1:n
hold on
for i=1:length(xcoordinates)%First loop gives the main body
plot(xcoordinates,y,"r")
end
for i=1:length(vectorn)%Second loop offers all the posibilities of that remainig tile, the problem is that in this script
%it puts all in the same graph with the loop above, how can I separate it?
op1=xcoordinates(1:5,vectorn)
plot(op1,y+cy)
figure(i)
xlim([-(6*b) 6*b]); ylim([-(6*c), 6*c])
set(gca,'ytick',-(6*c):c:6*c)
set(gca,'xtick',-(6*b):b:6*b)
grid on
end
hold off
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!