# Taking in 2 array variables, my output variable is a single number rather than an array. Any suggestions to get my output in an array?

조회 수: 1(최근 30일)
Kenneth Roszell 2020년 2월 13일
댓글: Stephen23 2020년 2월 14일
alpha = 30;
theta_1 = 0:360;
omega_1 = 360;
theta_2 = atan(tan(theta_1)/cos(alpha))
omega_2 = sec(theta_1).*sec(theta_1).*omega_1/((sec(theta_2)).*(sec(theta_2)).*cos(alpha))
If I remove the division, omega_2 is an array, but with it omega_2 is a single value and I don't understand why.
Any help would be greatly appreciated!
##### 댓글 수: 1표시숨기기 없음
darova 2020년 2월 13일

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

### 답변(1개)

Spencer Chen 2020년 2월 13일
I guess you probably want to use the:
A ./ B
operation instead of the straight divide "/".
Also as a recommendation, break up your expression into smaller pieces for easier debugging. e.g.:
numerator = sec(theta_1).*sec(theta_1).*omega_1;
denominator = (sec(theta_2)).*(sec(theta_2)).*cos(alpha);
or even finer pieces.
Blessings,
Spencer
##### 댓글 수: 2표시숨기기 이전 댓글 수: 1
Stephen23 2020년 2월 14일
"...operation instead of the straight divide "/"."
Which in MATLAB are called ridivide and mrdivide respectively. Read more about the difference:

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

### 범주

Find more on Operators and Elementary Operations 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!

Translated by