trailing string input must be double or native error

hi, i have a text file that i have attached. i am plotting the 4th column.but the curve has some disturbances. to smoothen the curve i used the average:
for i=2:250 a(i)=sum(y(i-1),y,y(i+1)) z(i)=a(i)/3 end
i am getting the following error: error using sum trailing string input must be "double" or "native". what is the errror?
thanks in advance.
regards, shiksha

2 件のコメント

shiksha
shiksha 2014 年 2 月 28 日
編集済み: shiksha 2014 年 2 月 28 日
for i = 2:249 z(i) = sum(y(i-1:i+1))/3; end
how to display the answer z that i have obtained? i am just able to plot it.. and i want to plot the differential of z with time(5th column in text file), so i used: plot(diff(z)./diff(m(1:250,5)),'x') but i am getting an error : error using ==>rdivide matrix dimensions must agree..
the size of z is 1 249 the size of m(:,5) is 250 1 can u just tell me what is the error? please help..
regards, shiksha
shiksha
shiksha 2014 年 2 月 28 日
i got the answer. i just hd to transpose one input.

サインインしてコメントする。

 採用された回答

Mischa Kim
Mischa Kim 2014 年 2 月 27 日
編集済み: Mischa Kim 2014 年 2 月 27 日

0 投票

Shiksha, I assume your text file has 250 rows? If that's the case in the statement
a(i)=sum(y(i-1),y,y(i+1))
you are accessing for i=250 the 251 st element, y(i+1), which results in the error. Also, the middle term does not access a particular element. Finally, unless you need matrix a, you could simply do
for i = 2:249
z(i) = sum(y(i-1:i+1))/3;
end

3 件のコメント

shiksha
shiksha 2014 年 2 月 28 日
thanks. its working now.
shiksha
shiksha 2014 年 2 月 28 日
do u know how to apply low pass filter to smoothen the curve?
shiksha
shiksha 2014 年 2 月 28 日
how to display the answer z that i have obtained? i am just able to plot it.. and i want to plot the differential of z with time(5th column in text file), so i used: plot(diff(z)./diff(m(1:250,5)),'x') but i am getting an error : error using ==>rdivide matrix dimensions must agree..
can u just tell me what is the error? please help..
regards, shiksha

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeFit Postprocessing についてさらに検索

タグ

質問済み:

2014 年 2 月 27 日

コメント済み:

2014 年 2 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by