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

1 view (last 30 days)
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 Comments
Cris LaPierre
Cris LaPierre on 28 Dec 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 on 28 Dec 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!

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 28 Dec 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.

More Answers (0)

Categories

Find more on Time-Frequency Analysis in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!