trailing string input must be double or native error

4 visualizzazioni (ultimi 30 giorni)
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 Commenti
shiksha
shiksha il 28 Feb 2014
Modificato: shiksha il 28 Feb 2014
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 il 28 Feb 2014
i got the answer. i just hd to transpose one input.

Accedi per commentare.

Risposta accettata

Mischa Kim
Mischa Kim il 27 Feb 2014
Modificato: Mischa Kim il 27 Feb 2014
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 Commenti
shiksha
shiksha il 28 Feb 2014
do u know how to apply low pass filter to smoothen the curve?
shiksha
shiksha il 28 Feb 2014
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

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by