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

31 visualizzazioni (ultimi 30 giorni)

Risposte (2)

Vignesh Murugavel
Vignesh Murugavel il 4 Ago 2021
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 Commenti
Ivy
Ivy il 4 Ago 2021
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 il 4 Ago 2021
On line 15 of your code you have '-5'. What did you intend by the 5 part of that?

Accedi per commentare.


reza
reza il 11 Nov 2023
Modificato: Walter Roberson il 12 Nov 2023
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 Commenti
Walter Roberson
Walter Roberson il 12 Nov 2023
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 il 12 Nov 2023
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.

Accedi per commentare.

Categorie

Scopri di più su Stateflow Programmatic Interface in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by