0
votes

I am trying to create a 3D plot. I am trying to use the values from xvals and yvals to get a Z value,but I am getting two errors. One is saying that the data dimensions should agree and its also saying that the mesh(X,Y,Z) has an error while evaluating callback. Any suggestions to get this to plot? Thanks

        xvals = 1.00:0.1:5.75;
        yvals = 2.5:0.1:12.5;
        [X,Y] = meshgrid(xvals,yvals);

        AB01 = sqrt((-21.6 - X).^2 + (-5.612 - Y).^2);
        AA0 = 22.269;
        pivotlength = sqrt(X.^2 + Y.^2);
        l = AB01-7.5;
        b = (pivotlength.^2 + AB01.^2 - AA0^2);
        ee = (2*pivotlength.*AB01); 
        bb= b/ee;
        thetalmax = acosd(bb);

        c = (pivotlength.^2 + l.^2 -AA0^2)/(2*pivotlength.*l);
        thetalmin = acosd(c);


        Z = thetalmin - thetalmax ; 

        mesh(Y,X,Z);
1

1 Answers

0
votes

You have problems with the dimensions. I think I fixed it:

xvals = 1.00:0.1:5.75;
yvals = 2.5:0.1:12.5;

[X,Y] = meshgrid(xvals,yvals'); % added '

    AB01 = sqrt((-21.6 - X).^2 + (-5.612 - Y).^2);
    AA0 = 22.269;
    pivotlength = sqrt(X.^2 + Y.^2);
    l = AB01-7.5;
    b = (pivotlength.^2 + AB01.^2 - AA0^2);
    ee = (2*pivotlength.*AB01); 
    bb= b./ee; % added .
    thetalmax = acosd(bb);

    c = (pivotlength.^2 + l.^2 -AA0^2)./(2*pivotlength.*l);% added .
    thetalmin = acosd(c);


    Z = thetalmin - thetalmax ; 

    mesh(Y,X,Z);

BUT

you'l now get an error because Z values are complex. But that's a problem of initial values I think