フィルターのクリア

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

2 ビュー (過去 30 日間)
UET Hussain
UET Hussain 2018 年 2 月 23 日
コメント済み: KSSV 2018 年 2 月 23 日
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 件のコメント
UET Hussain
UET Hussain 2018 年 2 月 23 日
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 2018 年 2 月 23 日
polyfit gives you slope and y-intercept of your straight line.....using these you need to draw you line.....you are not doing that....

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

採用された回答

KSSV
KSSV 2018 年 2 月 23 日
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 件のコメント
UET Hussain
UET Hussain 2018 年 2 月 23 日
編集済み: UET Hussain 2018 年 2 月 23 日
slop = p(1); %Please see its "p", not "y1"
intercept = p(2);
KSSV
KSSV 2018 年 2 月 23 日
p = polyfit(x,y,1);
it has slope already....

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDiscrete Data Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by