Why I am getting "Error Using Plot , invalid color or line type " in line 15

25 次查看(过去 30 天)

回答(2 个)

Vignesh Murugavel
plot3(X,Y,Z) plots coordinates in 3-D space.
  • To plot a set of coordinates connected by line segments, specify X, Y, and Z as vectors of the same length.
  • To plot multiple sets of coordinates on the same set of axes, specify at least one of X, Y, or Z as a matrix and the others as vectors.
  3 个评论
Ivy
Ivy 2021-8-4
I have have a perspective camera with a focal point at (0,0,0), a focal length of 1, and an image plane equal to the z=1 plane. Need to consider an object O with four 3D co-ordinates (-1, 0, 2), (1, 0, 5), (0, 1, 4), (0, -1, 3).
I need to write a function that will take as input a set of 3D points and returns as output a set of 2D points (𝑝1 , 𝑝2 , 𝑝3 , 𝑝4 ) that are the projection of the 3D points with the perspective camera. Then Write the second function to project the points using weak perspective projection (𝑞1 , 𝑞2 , 𝑞3 , 𝑞4 ). Note that the scale factor should be based on the average distance to all points.
Please help with code computing, I am very new to Matlab, I have no experience. This is what I was able to compute. I am stuck

请先登录,再进行评论。


reza
reza 2023-11-11
编辑:Walter Roberson 2023-11-12
clc;
clear;
close all;
y=-1:10;
G=1:10;
c=5;
t=10;
D=3;
u_y='((-G*y^2)/2)+(c*y)+(t*y)+(4((t^(1/2)/3*G)*((c-G*y)^(3/2))+D)';
plot(y,u_y)
Error using plot
Invalid color, marker, or line style.
xlabel('y')
ylablel('u_y')
  2 个评论
Walter Roberson
Walter Roberson 2023-11-12
y=-1:10;
G = (1:10).';
c=5;
t=10;
D=3;
u_y=((-G.*y.^2)/2)+(c.*y)+(t.*y)+(4.*((t.^(1/2)/3.*G).*((c-G.*y).^(3/2))+D));
plot(y,u_y)
Warning: Imaginary parts of complex X and/or Y arguments ignored.
xlabel('y')
ylabel('u_y')
Walter Roberson
Walter Roberson 2023-11-12
Note that your y and G are different sizes -- 12 and 10 -- so you cannot combine them by element-by-element operations... not unless you transpose one of them and use implicit expansion.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Stateflow Programmatic Interface 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by