Unable to perform assignment because the size of the left side is 1-by-10 and the size of the right side
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Bradley Kitzul
il 27 Dic 2020
Commentato: Walter Roberson
il 29 Dic 2020
Hi, I am getting this error message.
Unable to perform assignment because the size of the left side is 1-by-10 and the size of the right side
is 1-by-6.
Error in codeRun (line 57)
[z_1,b(1, 1:10),terms_1,candIndex(1, 1:9)]= FOS(inp1,N/3,M,NO,trm1,t);
I am not sure why I am getting this error message as the only thing I am changing is getting rid of white gaussian noise to my signal (commented out and replaced it with just y.
% adding white gaussian noise to the signal
%in1=y;
%v = awgn(y,5,'measured');
%in=in1+v;
in = y;
Sorry if my question in rudimentary, I am new to coding! Thank you :D
2 Commenti
Cris LaPierre
il 28 Dic 2020
We don't have enough of your code to really say for certain why this change is causing this error. For starters, please include the entire error message (all the red text).
You might consider attaching your code and data files if there are any using the paperclip icon so we can try to reproduce the error on our end.
Risposta accettata
Walter Roberson
il 28 Dic 2020
if (abs(Qmax) < abs(Q1))
noise=1; % only noise remains
else
% complete searching
mse=mse-Qmax;
D=Dmax;
p=pmax;
c=cmax;
g=gmax;
alpha=alphamax;
m=m+1;
end
When you detect noise, you do not increase m . There will be a variable number of segments detected as noise, so you expect a variable output for m.
M=m-1;
terms=M; %# of terms chosen by FOS
So M is expected to vary in size.
a(1)=g(M);
for i=1:M
v(i) = 1;
for m = i+1:M
v(m) = - sum(alpha(m, i:m-1) .* v(i:m-1));
end
a(i) = sum(g(i:M) .* v(i:M));
end
You create up to a(M), so a will vary in size.
[z_1,b(1, 1:10),terms_1,candIndex(1, 1:9), eratio]= FOS(inp1,N/3,M,NO,trm1,t);
but your code is expecting a vector of exactly 10 values each time.
M=10;% Maximum term to add
Notice the "maximum". Not a fixed number, a maximum.
Your code should be receiving the output into an un-indexed variable, and doing something with results that are shorter because noise was detected. Pad them with zeros or something. And only then write the result into b.
2 Commenti
Walter Roberson
il 29 Dic 2020
[z_1,bt,terms_1,candIndex(1, 1:9), eratio]= FOS(inp1,N/3,M,NO,trm1,t);
bt(11)=0; %pad short
b(1,1:10) = bt(1:10);
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Time-Frequency Analysis in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!