matlab 为什么会出现Z must be a matrix,not a scalar or vector for i=2:1:5Xp(i)=R*cos(200*i)-(R1+R3)*cos(13*i);Yp(i)=R*sin(200*i)+(R1+R3)*sin(13*i);for j=2:1:i-1if Xp(i)==Xp(j)&Yp(i)==Yp(j)Zp(i)=Zp(j)-0.1;else Zp(i)=8-0.1;endendsurf(Xp(i),Yp(i),Z
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/23 22:24:43
matlab 为什么会出现Z must be a matrix,not a scalar or vector for i=2:1:5Xp(i)=R*cos(200*i)-(R1+R3)*cos(13*i);Yp(i)=R*sin(200*i)+(R1+R3)*sin(13*i);for j=2:1:i-1if Xp(i)==Xp(j)&Yp(i)==Yp(j)Zp(i)=Zp(j)-0.1;else Zp(i)=8-0.1;endendsurf(Xp(i),Yp(i),Z
matlab 为什么会出现Z must be a matrix,not a scalar or vector
for i=2:1:5
Xp(i)=R*cos(200*i)-(R1+R3)*cos(13*i);
Yp(i)=R*sin(200*i)+(R1+R3)*sin(13*i);
for j=2:1:i-1
if Xp(i)==Xp(j)&Yp(i)==Yp(j)
Zp(i)=Zp(j)-0.1;
else Zp(i)=8-0.1;
end
end
surf(Xp(i),Yp(i),Zp(i))
hold on
end
matlab 为什么会出现Z must be a matrix,not a scalar or vector for i=2:1:5Xp(i)=R*cos(200*i)-(R1+R3)*cos(13*i);Yp(i)=R*sin(200*i)+(R1+R3)*sin(13*i);for j=2:1:i-1if Xp(i)==Xp(j)&Yp(i)==Yp(j)Zp(i)=Zp(j)-0.1;else Zp(i)=8-0.1;endendsurf(Xp(i),Yp(i),Z
我猜你的代码应该是 surf(Xp(i),Yp(i),Zp(i)) 出错了吧,当x和y为1*10的向量时,则构成了一个10*10的二维平面,因此此时z应该是一个10*10的矩阵,而不是标量或矢量,错误提示:Z must be a matrix,not a scalar or vector 就是这个意思.