no puedo plotear en mi codigo

2 Ansichten (letzte 30 Tage)
Ricardo David am 30 Okt. 2022
Beantwortet: Gokul Nath S J am 26 Mai 2023
%R2=2;
%h=100;
%descenso
tr=linspace(pi,0,100);
tr1=linspace(2*pi,pi,100);
tr12=linspace(pi,0,100);
%elipse externa
a=[3*cos(tr) 3*cos(tr1)];
b=[3*sin(tr) 3*sin(tr1)-6];
%interna
a1=[2*cos(tr) 2*cos(tr1)];
b1=[2*sin(tr) 2*sin(tr1)-6];
% la separacion para cada banda es = b
c=[(bi*tr12)/2*pi];
c=[c+14 c+13 c+12 c+11 c+10 c+9 c+8 c+7 c+6 c+5 c+4 c+3 c+2 c+1];
%ascenso
tr2= linspace(0,pi,100); tr22=linspace(pi,2*pi,100); tr23=linspace(0,pi,100);
a2=[3*cos(tr2) 3*cos(tr22)];
b2=[3*sin(tr2) 3*sin(tr22)-4];
%interna
a3=[2*cos(tr2) 2*cos(tr22)];
b3=[2*sin(tr2) 2*sin(tr22)-6];
%separacion es de 2
c1=[(bi*tr23)/(2*pi)];
c1=[c1+0 c1+2 c1+4 c1+6 c1+8 c1+10 c1+12 c1+14];
for i=1:3
a=[a a];
b=[b b];
a1=[a1 a1];
b1=[b1 b1];
a2=[a2 a2];
b2=[b2 b2];
a3=[a3 a3];
b3=[b3 b3];
end
tz=linspace (0,pi/4,100);
tz1=linspace(pi/4,pi/2,100);
a4=[3*cos(tz) cos(3*pi/2)-tz1];
b4=[3*sin(tz)-6 sin((3*pi/2)-tz1)];
a5=[cos(tz) 3*cos((3*pi/2)-tz1)];
b5=[sin(tz)-6 3*sin((3*pi/2)-tz1)];
c2=c1(end)*ones(1,200);
%graficas
plot3(a2,b2,c1,'r');
Error using plot3
Vectors must be the same length.
hold on
plot3(a3,b3,c1,'m');
plot3(a,b,c,'r');
hold on
plot3(a1,b1,c,'b');
plot3(a4,b4,c2,'g');
plot3(a5,b5,c2,'c');
xlim([-3 3]);
xlabel('axis x')
ylabel('axis y')
zlabel('axis z')
hold off
1 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
Jan am 30 Okt. 2022
I've included the error message in the question. It is easier to solve a problem than to guess, what the problem is.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Gokul Nath S J am 26 Mai 2023
Hi Ricardo,
It seems that you are receving an error mentioning the vectors are of different length. The variable c1 is of length 800 while the other variables a2 and b2 are 1600. Please note that this difference is attributed to the fact that you are concatinating two matrixes together in the following lines.
a2=[3*cos(tr2) 3*cos(tr22)];
b2=[3*sin(tr2) 3*sin(tr22)-4];
Since the objective of the function is not mentioned in the question, as I workaround, I would suggest you check the dimension of the a2, b2 and c1 variable and understand whether there is a requirement for the concatenation or you might have missed the concatination of the variable c1.
with regards,
Gokul Nath S J
0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu MATLAB Report Generator finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by