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

3 views (last 30 days)
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.

Answers (1)

Josh Meyer
Josh Meyer on 11 Nov 2013
Edited: Josh Meyer on 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)

Categories

Find more on Function Creation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!