Azzera filtri
Azzera filtri

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

2 visualizzazioni (ultimi 30 giorni)
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 Commenti
UET Hussain
UET Hussain il 23 Feb 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 il 23 Feb 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....

Accedi per commentare.

Risposta accettata

KSSV
KSSV il 23 Feb 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 Commenti
UET Hussain
UET Hussain il 23 Feb 2018
Modificato: UET Hussain il 23 Feb 2018
slop = p(1); %Please see its "p", not "y1"
intercept = p(2);

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Discrete Data Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by