Borrar filtros
Borrar filtros

I want to plot trend line (and want to record its slop) to multiple figures

2 visualizaciones (últimos 30 días)
Good Day, I have almost 50,000 points single column data. I divided it into 6 equal parts, calculated rms for each part, and want to plot trending curve of each part. For polyfit, I don't have values of x. I don't know why, but lsline is also not showing anything.
T = 6*fix(numel(V1)/6);
six_parts = reshape(V1(1:T),[],6);
for i = 1:6
sp1= six_parts(:,i);
P1 = sp1;
Pa1 = WinSize*fix(numel(P1)/WinSize); %numel(V1) counts number of elements in V1. it is numeL, not 1(one); fix(A) will round the number to nearest intiger
rP1 = rms(reshape(P1(1:Pa1),WinSize,[]),1);
figure;
% h1 = lsline
plot (rP1);
tmean(i) = trimmean(rP1,10)
xlswrite('abc',tmean);
Any suggestion is welcome
  3 comentarios
UET Hussain
UET Hussain el 23 de Feb. de 2018
i tried this, but polyfit is not giving any output..... (means no trend line has been shown)
if true
T = 6*fix(numel(N)/6);
six_parts = reshape(N(1:T),[],6);
for i = 1:6
sp1= six_parts(:,i);
x= 1:length(sp1);
x=x';
P1 = sp1;
Pa1 = WinSize*fix(numel(P1)/WinSize); %numel(V1) counts number of elements in V1. it is numeL, not 1(one); fix(A) will round the number to nearest intiger
rP1 = rms(reshape(P1(1:Pa1),WinSize,[]),1);
figure;
plot (sp1);
polyfit(x,sp1,1);
tmean(i) = trimmean(sp1,10)
xlswrite('abc',tmean);
end
am i putting polyfit at right position????
KSSV
KSSV el 23 de Feb. de 2018
polyfit gives you slope and y-intercept of your straight line.....using these you need to draw you line.....you are not doing that....

Iniciar sesión para comentar.

Respuesta aceptada

KSSV
KSSV el 23 de Feb. de 2018
Use polyfit like below to draw a line later:
x = linspace(0,4*pi,10);
y = sin(x);
% Use polyfit to fit a line to the points
p = polyfit(x,y,1);
% Evaluate the polynomial on a finer grid and plot the results.
x1 = linspace(0,4*pi);
y1 = polyval(p,x1);
figure
plot(x,y,'o')
hold on
plot(x1,y1)
hold off
  3 comentarios
UET Hussain
UET Hussain el 23 de Feb. de 2018
Editada: UET Hussain el 23 de Feb. de 2018
slop = p(1); %Please see its "p", not "y1"
intercept = p(2);

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Discrete Data Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by