Question
Tn this Question https://www.chegg.com/homework-help/questions-and-answers/1-smoothing-filter-smoothing-filter-averages-rapid-changes-data-set-typically-used-remove--q30368992 when u run function function smoothed=CTask2p1_f(x,width) smoothed=zeros(size(x)); if rem(width,2)==0 width=width+1; disp('width is even. Converting to odd by incrementing by 1') end
Tn this Question
https://www.chegg.com/homework-help/questions-and-answers/1-smoothing-filter-smoothing-filter-averages-rapid-changes-data-set-typically-used-remove--q30368992
when u run function
function smoothed=CTask2p1_f(x,width) smoothed=zeros(size(x)); if rem(width,2)==0 width=width+1; disp('width is even. Converting to odd by incrementing by 1') end f1 = conv(x,ones(1,width),'same')/width; smoothed(width-fix(width/2):length(x)-fix(width/2))=f1(width-fix(width/2):length(x)-fix(width/2)); for n = 1:(width-fix(width/2))-1 smoothed(n)= mean([x(1:n-1),x(n:n+n-1)]); end for n=(width-fix(width/2))-1:-1:1 j=length(x)-n+1; w=length(x)-j; smoothed(j)=mean([x(j),x(j-w:j-1),x(j+1:length(x))]); end
it gives this error:
Index exceeds matrix dimensions.
Error in CTask2p1_f (line 10) smoothed(n)= mean([x(1:n-1),x(n:n+n-1)]);
how to solve it
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started