Info

此问题已关闭。 请重新打开它进行编辑或回答。

Error using ==> times Matrix dimensions must agree

1 次查看(过去 30 天)
i cant find the error guys please help..
clear
clc
fs=50e6;
ts=1/fs;
n=fs/1000;
chprt=511e3;
x=0:1/chprt:0.001;
xi=0:1/fs:0.001-1/fs;
fdlo=-10e3;
fdhi=10e3;
f= [fdlo:1000:fdhi];
M = length(f);
g = 50000;
gg = 1:g;
loop=100;
nn=[0:n-1];
t=0:ts:0.001-ts;
startpt=0;
datatype='ubit1';
load CAcode_511;
record = mseq;
record = [record 0];
recordI= fopen('C:/Users/Frangos/Desktop/14h 22m 36s 046ms/ChannelI.misl', 'rb');
recordQ=fopen('C:/Users/Frangos/Desktop/14h 22m 36s 046ms/ChannelQ.misl', 'rb');
sig = interp1(x,record,xi);
sig=sign(sig);
w = zeros (loop,2);
for z=1:loop;
dataI = fread(recordI,[1 50000],'ubit1'); %x6
dataI = 2.*dataI-1;
dataQ = fread(recordQ,[1 50000], 'ubit1');
dataQ = 2.*dataQ-1;
imf = zeros(M,length(t));
for k=1:M
signal1= fft(sig.*exp(1i*2*pi*f(k).*t));
signal2= fft(dataI+dataQ*1i);
mf=signal2.*conj(signal1);
imf(k,:)= abs(ifft(mf));
% plot(t,imf(k,:));
end
[r,c] = find(imf==max(max(imf)));
freq = (r-11)*1000;
d = c;
w(z,:) = [freq,d];
%surf(t,f,imf);
end
fseek(recordI, 0, 'bof'); %Move to specified position in file
status = fseek(recordI, 0, 'bof');
fseek(recordQ, 0, 'bof'); %Move to specified position in file
status = fseek(recordQ, 0, 'bof');
mf1=zeros(1);
mfrq0 = zeros(1);
mfrq1 = zeros(1);
c0= zeros(1);
f0=zeros(1);
frr=zeros(1);
for z2= 1:loop
f0(z2) = w(z2,1);
c0(z2) = w(z2,2);
dataI = fread(recordI,6*50000,'ubit1');
dataI = 2.*dataI-1;
dataQ = fread(recordQ,6*50000,'ubit1');
dataQ = 2.*dataQ-1;
z1 = dataI + 1i*dataQ;
za2 = z1(c0(z2):c0(z2)+5*n-1);
zaa2 = za2' .* [sig sig sig sig sig];
for z3 = [1:3];
fr = f0(z2) -400+400*(z3-1);
==>mfrq0(z3) = sum(zaa2(1:250000) .* exp(1i*2*pi*(fr)*ts*nn));
mfrq1(z3) = abs(mfrq0(z3));
end
[mamp mrw] = max(mfrq1);
mf1(z2) = mrw-2;
mfrq(z2) = f0(z2) + 200 * (mrw-2);
mfrt=mfrq(z2);
plot(mfrq);
xlabel('time(ms)');
ylabel('frequency(Hz)');
end
the error is there ==> 10 lines above

回答(1 个)

Walter Roberson
Walter Roberson 2013-3-16
You have fs = 50e6 and n = fs/1000 so n will be 50e3 which is 50000 . Then nn is 0:n-1 so nn will be 50000 elements long. You then, in the line having trouble, try to multiply the vector 50000 elements long by 250000 elements of zaa2 .
If the number of elements in nn is calculated, the number of elements to extract from zaa2 should also be calculated.

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by