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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!