Error using * Inner matrix dimensions must agree urgent help please.

1 回表示 (過去 30 日間)
Or Peer
Or Peer 2019 年 4 月 28 日
コメント済み: Stephen23 2019 年 4 月 29 日
I got this prompt and I dont know how to solve it.
function water_vec=water_light_ray_vec(air_vec,refractive_index)
normal_vec=[0
0
1];
% normal_vec=[0;0;1];
water_vec=(air_vec-normal_vec*(air_vec*normal_vec-sqrt(air_vec*normal_vec-1+refractive_index^2)))/refractive_index ;
end
refractive index size is 1.33 1 by 1
normal_vec is [0
0
1]
air_vec is [-0.173230940506992
-0.116707951859014
0.667867059147687]
help will be very appreciated.

採用された回答

Geoff Hayes
Geoff Hayes 2019 年 4 月 28 日
Or - the error is due to the following multiplciation
air_vec*normal_vec
where both arrays/vectors are 3x1 and so the error message makes sense. What do you want to be doing here? Multiplying the two to get a scalar or do you want to keep the 3x1 dimensions?
  2 件のコメント
Or Peer
Or Peer 2019 年 4 月 28 日
I would like to keep the 3x1 dimensions, thank you for the help.
Geoff Hayes
Geoff Hayes 2019 年 4 月 29 日
try
air_vec .* normal_vec

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by