Error 'Inner dimensions matrix must agree'
2 ビュー (過去 30 日間)
古いコメントを表示
I am making a matlab code for my project so I am receiving this "Inner dimnension matrix must agree'. My code is as follows:-
t = 0:0.01:2;%time in seconds
N = 6;%Number of paths
B = [0.2 0.7 0.4 0.3 0.8 0.6];%path gain
Angle = [pi/9 pi/4 pi/6 pi/3 pi/5 pi/2] ;%angles of arrival
varphi = [(1/3)*pi (2/3)*pi (3/3)*pi (4/3)*pi (5/3)*pi (6/3)*pi];%varphi_n for the nth path
fc = 900;%carrier frequency in MHz
fd = 1;%%doppler frequency in Hz
pcpd = varphi-((2*pi*fd)*cos(Angle)*t);%path carrier phase distortion
x = B*exp(j*pcpd);
Please let me know whats going on. Thanks in advance!
2 件のコメント
the cyclist
2017 年 12 月 11 日
In the line that gives the error, you are trying to matrix-multiply cos(Angle), which is a vector of length 6, and t, which is a vector of length 201.
What is is that you expect out of that operation?
Kaushik Lakshminarasimhan
2017 年 12 月 11 日
編集済み: Kaushik Lakshminarasimhan
2017 年 12 月 11 日
Looks like you are trying to compute phase distortion of 6 different paths at 201 different time points. You're getting an error because you are trying to multiply cos(Angle) (a vector of length 6) with t (a vector of length 201).
The correct way to solve this is by computing your variables -- pcpd and x -- for each path at each time point. You can do this using a nested for loop. An alternative (faster) way is to vectorize your code and using the .* operator to perform element-wise multiplication. Either way, it is important to break down the problem into smaller pieces before plugging in the formula.
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!