필터 지우기
필터 지우기

Arrays have incompatible sizes for this operation

조회 수: 5 (최근 30일)
Miguel Albuquerque
Miguel Albuquerque 2022년 7월 12일
댓글: Miguel Albuquerque 2022년 7월 12일
Hey guys, thanks in advance.
Im trying to apply this equation on matlab
However i Keep getting this error , arrays have incompatible sizes for this operation, I dont understand since there are only constants and when there is a vector I do this .*
This is the code:
D is not getting any error, only H_BAC.
I ve attached the data
n=1;
u=2;
Lp=1;
fc=30e6;
c=3e8;
Vr=250;
D=sqrt(1-((u.^2*doppler_freqSurv.^2*c.^2)/4*Vr.^2*fc.^2));
H_BAC=exp(1*j*2*pi*((R1_matrix-Rm_matrix+n*Lp)/c*fc .*D));

답변 (1개)

Voss
Voss 2022년 7월 12일
R1_matrix and Rm_matrix are 1x400:
load R1_matrix
load Rm_matrix
whos R*
Name Size Bytes Class Attributes R1_matrix 1x400 3200 double Rm_matrix 1x400 3200 double
Therefore, the expression involving subtracting Rm_matrix from R1_matrix gives a 1x400 vector (here stored as the variable temp):
n=1;
u=2;
Lp=1;
fc=30e6;
c=3e8;
Vr=250;
temp = (R1_matrix-Rm_matrix+n*Lp)/c*fc;
whos temp
Name Size Bytes Class Attributes temp 1x400 3200 double
The result of that expression should be multiplied element-wise by D, but D is 1x8000:
load D
whos D
Name Size Bytes Class Attributes D 1x8000 128000 double complex
So you can't do it:
H_BAC=exp(1*j*2*pi*(temp.*D));
Arrays have incompatible sizes for this operation.
Hard to say what the right thing to do is with the information given.
  댓글 수: 8
Miguel Albuquerque
Miguel Albuquerque 2022년 7월 12일
n=1;
u=2;
D=sqrt(1-((u.^2*doppler_freqSurv.^2*c.^2)/4*Vr.^2*fc.^2));
R1_matrix=[zeros(1,size(doppler_freqSurv,1)-size(R1_matrix,1)) R1_matrix] %padding ahead
This is not changing anything in R1
Miguel Albuquerque
Miguel Albuquerque 2022년 7월 12일
Here it is the best way, thanks anyways
R1_matrix(numel(D))=0;

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

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by