Vectors must be the same length
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
my code says "vectors must be the same length" really new to matlab.
load("lnu (1).mat")
plot(xy,'.');
axis equal;
hold on
s=[1 0;0 -1];
b=xy'*s;
t=[cos(2*pi/3) -sin(2*pi/3);sin(2*pi/3) cos(2*pi/3)];
a=xy'*t;
plot(xy,a,b,'.');
axis equal;
0 comentarios
Respuestas (1)
Voss
el 2 de Dic. de 2021
plot takes vectors in pairs of arguments, like plot(x1,y1,x2,y2, ...)
The second call to plot in your code uses three numeric arguments, so plot's going to treat xy as a vector of x-values and a as a vector of corresponding y-values, but I suspect that they don't have the same number of elements. (Can't say for sure because I don't have the data, but this is a guess based on the error message.)
Try splitting the variable xy into its x and y parts and send it as two consecutive arguments in both calls to plot, e.g., plot(xy(:,1),xy(:,2)) or plot(xy(1,:),xy(2,:)), depending on how xy is arranged (again, can't say for sure without the data.)
0 comentarios
Ver también
Categorías
Más información sobre Annotations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!