Divide a row vector with a column vector with different dimensions

I have a problem with dividing a row vector with a column vector both different functions Quickly here is the problem from begining
the equation I want to solve for is EPD = ((H * Lambda) / (Q * GSD)) H = [500:100:1000] Q = [0.2:0.1:2] Lambda and GSD are Constants
What I have done is I created a new vector called HandLambda (Multiplied the constant Lambda with vector H) and Another vector called QandGSD (Mulitplied the constant GSD with the vector Q) then I trasnposed the new vector QandGSD and called it QandGSDreverse (Its now a column vector)
My problem now I'm trying to divide those two new vectors (different dimentions so EPD = ((H * Lambda) / (Q * GSD)) = HandLambda ./ QandGSDreverse
The division is NOT working I thought a row vector can easily be divided with a column vector even with different dimentions
Any thoughts and Ideas?? Also I'm open to change the way this can be solved!

1 comentario

What would you expect the result to be of dividing two vectors of different size? Which elements should divide by what and what happens to the excess elements in either vector?

Iniciar sesión para comentar.

 Respuesta aceptada

Massimo Zanetti
Massimo Zanetti el 7 de Oct. de 2016
Editada: Massimo Zanetti el 7 de Oct. de 2016
Better if you use same sized vectors. And use './' instead of '/' to do element wise division.
%number of points
n=100;
%euqally subdivide your variable intervals
H = linspace(500,1000,n);
Q = linspace(0.2,2,n);
%constants
Lambda=1;
GSD = 2;
%equaiton
EPD = (H * Lambda) ./ (Q * GSD) ;

3 comentarios

The thing is there has to be a specific interval H has to have an intervals of 100 so its 500,600,700,800,900,1000 also Q needs to be seperated by 0.1 so its 0.2,0.3,0.4, ... 2
I'm doing a trade study for a spacecraft constellation we are trying to devide to what altitude we will place the spacecraft thats why we need to try all values from 500KM to 1000KM the Q value is another parameter and needs to be specific with the intervals
thats why both vectors has to be with different dimentions
Then you have to compute a GRID of values.
H = [500:100:1000]; Q = [0.2:0.1:2] ;
[H,Q]=meshgrid(H,Q);
EPD = (H * Lambda) ./ (Q * GSD) ;
and your result will be a surface
surf(H,Q,EDP);
Massimo,
You saved my life yes the meshgrid worked. So at the end the matrix size HAS to match and this meshgrid just matched them by creating same values repeated
Thanks alot Massimo ;)

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by