Info

This question is closed. Reopen it to edit or answer.

ao*ud Error using * Inner matrix dimensions must agree...

2 views (last 30 days)
u_basic= input( 'Signal elements (row complex vector, each element last tb sec) = ? ');
m_basic=length(u_basic); %returns the largest array dimension in matrix
fcode=input(' Allow frequency coding (yes=1, no=0) = ? ');
if fcode==1
f_basic=input(' Frequency coding in units of 1/tb (row vector of same length) = ? ');
end
F=input(' Maximal Doppler shift for ambiguity plot [in units of 1/Mtb] (e.g., 1)= ? ');
K=input(' Number of Doppler grid points for calculation (e.g., 100) = ? ');
%F=float(F);
df=F/K/m_basic;
T=input(' Maximal Delay for ambiguity plot [in units of Mtb] (e.g., 1)= ? ');
N=input(' Number of delay grid points on each side (e.g. 100) = ? ');
sr=input(' Over sampling ratio (>=1) (e.g. 10)= ? ');
r=ceil(sr*(N+1)/T/m_basic);
if r==1
dt=1;
m=m_basic;
uamp=abs(u_basic);
phas=uamp*0;
phas=angle(u_basic);
if fcode==1
phas=phas+2*pi*cumsum(f_basic);
end
uexp=exp(j*phas);
u=uamp.*uexp;
else
dt=1/r;
ud=diag(u_basic);
ao=ones(r,m_basic);
m=m_basic*r;
*u_basic=reshape(ao*ud,1,m)* ;
uamp=abs(u_basic);
phas=angle(u_basic);
u=u_basic;
if fcode==1
ff=diag(f_basic);
phas=2*pi*dt*cumsum(reshape(ao*ff,1,m))+phas;
uexp=exp(j*phas);
u=uamp.*uexp;
end
end
The bold line having the reshape function works fine but the two matrix ao and ud are of incompatible dimension for matrix multiplication,When i evalute ao*ud,i got the error ao*ud... Error using * Inner matrix dimensions must agree......Could you plz explain how the Reshape function is working evenif the matrix multiplication isn't possible...
  1 Comment
dpb
dpb on 24 Dec 2014
Wouldn't seem like it should. Use the debugger and show us the actual results of size at that point on the arguments in the call; I'm guessing they were conformant when it succeeded.
Only other explanation is that the JIT optimizer did something clever since the result is a row vector and one of the inputs is ones and didn't actually do the full multiplication. I'd be surprised somewhat if the optimizer is that aggressive, but suppose it's at least possible. I think the real answer is that for the case that worked the sizes really were consistent.

Answers (0)

Community Treasure Hunt

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

Start Hunting!