Unable to perform assignment because the size of the left side is 1-by-10 and the size of the right side
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
Cris LaPierre
2020-12-28
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.
采纳的回答
Walter Roberson
2020-12-28
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 个评论
Walter Roberson
2020-12-29
[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);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Time-Frequency Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!