How can I repeat this line plot?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Thomas
el 30 de Jun. de 2016
Comentada: Thomas
el 4 de Jul. de 2016
Hi everyone,
The code I am using is
clear all;
a0 = 1;
b0 = a0./4 .* [1 1 1];
a1 = a0./2 .* [0 1 1];
a2 = a0./2 .* [1 0 1];
a3 = a0./2 .* [1 1 0];
N1=2;
N2=2;
N3=2;
In = zeros(N1,N2,N3,3);
P = zeros(N1,N2,N3,3);
for n = 0:N1-1
for m = 0:N2-1
for l = 0:N3-1
In(n+1,m+1,l+1,1:3) = n.*a1+m.*a2+l.*a3;
P(n+1,m+1,l+1,1:3) = n.*a1+m.*a2+l.*a3 + b0;
end
end
end
In_plt = reshape(In,[N1*N2*N3,3]);
hold off
scatter3(In_plt(:,1),In_plt(:,2),In_plt(:,3), 'b','filled');
P_plt = reshape(P,[N1*N2*N3,3]);
hold on
scatter3(P_plt(:,1),P_plt(:,2),P_plt(:,3), 'r','filled');
line([P(1,1,1,1) In(1,1,1,1)],[P(1,1,1,2) In(1,1,1,2)],[P(1,1,1,3) In(1,1,1,3)]);
line([P(1,1,1,1) In(1+1,1,1,1)],[P(1,1,1,2) In(1+1,1,1,2)],[P(1,1,1,3) In(1+1,1,1,3)]);
line([P(1,1,1,1) In(1,1+1,1,1)],[P(1,1,1,2) In(1,1,1,2)],[P(1,1,l+1,3) In(1,1+1,1,3)]);
line([P(1,1,1,1) In(1,1,1,1)],[P(1,1,1,2) In(1,1,1+1,2)],[P(1,1,1,3) In(1,1,1+1,3)]);
hold off
view(3), axis vis3d
axis off
camproj perspective, rotate3d on
title('Diamond structure of Indium Phosphide')
And this produces
What I want to happen is to connect all of these points using line. The section of code which produces the line connections is
line([P(1,1,1,1) In(1,1,1,1)],[P(1,1,1,2) In(1,1,1,2)],[P(1,1,1,3) In(1,1,1,3)]);
line([P(1,1,1,1) In(1+1,1,1,1)],[P(1,1,1,2) In(1+1,1,1,2)],[P(1,1,1,3) In(1+1,1,1,3)]);
line([P(1,1,1,1) In(1,1+1,1,1)],[P(1,1,1,2) In(1,1,1,2)],[P(1,1,l+1,3) In(1,1+1,1,3)]);
line([P(1,1,1,1) In(1,1,1,1)],[P(1,1,1,2) In(1,1,1+1,2)],[P(1,1,1,3) In(1,1,1+1,3)]);
What can I do to reproduce this section of code for every connection?
Thanks in advance.
0 comentarios
Respuesta aceptada
Muhammad Usman Saleem
el 30 de Jun. de 2016
why you do not copy paste it into code, i think due to bluck in coding
try to access these lines through for loop.
Check it
3 comentarios
Muhammad Usman Saleem
el 1 de Jul. de 2016
Your code is bucky can you point out where are the lines you wish to repeat?
Más respuestas (0)
Ver también
Categorías
Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!