Filter löschen
Filter löschen

Vector size error or Polyfit

3 Ansichten (letzte 30 Tage)
Don
Don am 24 Okt. 2015
Bearbeitet: Don am 26 Okt. 2015
Am trying to detrend some ECG data using polyfit(). Error message is that X and Y vectors not the same size. But they are, I think:
Workspace:
ChannelFirst 1x92672 double t 92672x1 double
Here’s the code:
t = (1:length(ChannelFirst))';
subplot(2,1,1) plot(t,ChannelFirst), grid title 'ECG Signals with Trends', ylabel 'Voltage (mV)'
subplot(2,1,2) plot(t,ChannelFirst), grid xlabel Sample, ylabel 'Voltage (mV)'
Code works fine to this point. Plot looks correct. However,
opol = 6;
[p,s,mu] = polyfit(t,ChannelFirst,opol);
Error using polyfit (line 47) X and Y vectors must be the same size.
t and ChannelFirst appear to be the same size
can someone please help ? are t and Channelfirst not the X and Y vectors for polyfit?

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 24 Okt. 2015
[p,s,mu] = polyfit(t.',ChannelFirst,opol);
or
[p,s,mu] = polyfit(t,ChannelFirst.',opol);
One of your vectors is a row vector and the other is a column vector. You need to have them the same orientation.
  1 Kommentar
Don
Don am 26 Okt. 2015
Bearbeitet: Don am 26 Okt. 2015
Thank you very much. I could not find that clue in Polyfit() documentation, so took the tutorial code a face value (t' used there) When changed to t it works like a charm. Karma!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Multichannel Audio Input and Output finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by