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

조회 수: 33 (최근 30일)
Ivy
Ivy 2021년 8월 4일
댓글: Walter Roberson 2023년 11월 12일

답변 (2개)

Vignesh Murugavel
Vignesh Murugavel 2021년 8월 4일
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
Walter Roberson
Walter Roberson 2021년 8월 4일
On line 15 of your code you have '-5'. What did you intend by the 5 part of that?

댓글을 달려면 로그인하십시오.


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