Unable to perform assignment because the size of the left side is 1-by-10 and the size of the right side

1 Ansicht (letzte 30 Tage)
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 Kommentare
Cris LaPierre
Cris LaPierre am 28 Dez. 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.
Bradley Kitzul
Bradley Kitzul am 28 Dez. 2020
Hi, my files are attached.
The error arises when I replace lines 35-37 with 38 of codeRun... I am getting rid of the white gaussian noise added to the signal. Futhermore, that is the full error message.
Note: When running the code, if it gets stuck on gmax..just run the code again.
Let me know if you have any other questions. Thank you!

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 28 Dez. 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 Kommentare
Bradley Kitzul
Bradley Kitzul am 28 Dez. 2020
Hello again,
Thank you for the help! However, I am still a little confused on the solution. Sorry for the inconvenience.
Walter Roberson
Walter Roberson am 29 Dez. 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);

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Time-Frequency Analysis finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by