How can I get MATLAB to keep variables that are in a range?

3 visualizzazioni (ultimi 30 giorni)
I'm varying a vector to be crossed with another, but one of the values (angle) of the first vector [cos(a) sin(a) 0] X [cos(-0.4363) sin(-0.4363) 0]. The values of "a" must be varied from 0 to 180 and stored to be plotted on a graph. I've tried using the "for" function to get the values of the first vector but when I try to cross these values with the second vector I get an error stating that they are not the same size. Any help or tips would be appreciated.

Risposte (1)

Josh Meyer
Josh Meyer il 11 Nov 2013
Modificato: Josh Meyer il 12 Nov 2013
Here is one way to do it- just store the vectors as columns in the matrices.
X = linspace(0,pi/2,1000);
N = length(X);
A = [cos(X); sin(X); zeros(1,N)];
B = [cos(-0.4363).*ones(1,N); sin(-0.4363).*ones(1,N); zeros(1,N)];
C = cross(A,B)

Categorie

Scopri di più su Function Creation 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