简体   繁体   中英

how can I plot the span of a matrix 3x2 in matlab?

I tried this way:

    gl1 =
   -2.5000   -1.0000
    4.3301    1.7321
    0         0
syms a b
span=gl1(:,1)*a+gl1(:,2)*b
a=[-100:0.1:100];
b=[-100:0.1:100];
span=eval(span)

and then I'd do plot3(span). unfortunatly at the last row it gives me this error:

Error using vertcat
Dimensions of matrices being concatenated are not consistent.

Error in sym/eval (line 11)
s = evalin('caller',vectorize(map2mat(char(x))));

any idea? I've found someone using a polytope method to do it,but I have no idea where I can get or I how can I realize such method.

thanks you in advice.

edit:in this case the span should be a line,since the rank of my matrix is one,but the question stands for a matrix with rank 2.

Why use symbolics? This works like a charm:

gl1 =
   -2.5000   -1.0000
    4.3301    1.7321
    0         0

a=[-100:0.1:100];
b=[-100:0.1:100];

span=gl1(:,1)*a+gl1(:,2)*b

Remember that you need several inputs to plot3 , ie the x, y, and z-values. Thus it should be something like this:

plot3(span(1,:),span(2,:),span(3,:)) 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM