0

I'm having trouble plotting some time-series data in App Designer (using 2017b) on a UIAxes.

The original time-series data is very noisy, hence the loaded data (which the user selects by UIGetFile) gets detrended and notch filtered (the frequencies for the Notch are from a UITable, which the user enters) after checking the Welch PowerSpectra on a separate UIAxes.

I can easily get it to work outside of App Designer but it would be excellent to keep it all in the UIFigure and on the specified UIAxes (I can get the filtered timeseries data to display in a seperate plot, just not in the UIAxes [had the same trouble with the Spectrogram]).

Bx = app.Bx;                % Grabs data from loaded file
t = 0:(size(Bx,1)-1);       % Sets the time from size of data
t = t/Freq;                 % divides time by Frequency @ which the data is recorded
Bx1 = timeseries(Bx, t);    % Set the timeseries

FreqNotch = app.UITable.Data;              % Grab Frequencies to Notch from values entered in UITable
Bx1 = detrend(Bx,'constant');               % Get rid of the mean
ts1 = idealfilter(Bx1,FreqNotch,'Notch');  % Notch filter the data

plot(app.UIAxes, ts1);   % Doesn't work, returns error
plot(ts1);               % Does Work, just plots in a seperate figure

Error message is:

Error using plot. Data Must be numeric, datetime, duration or an array convertible to double.

B K
  • 16
  • 3

2 Answers2

0

With the info you've provided I suspect that the problem is in the way you're accessing data, in app.designer class data stored as "properties" usually is organized in cells.

In my experience modifying the syntaxis, you're using for accessing data (curly brackets, parenthesis, dot notation, etc.) will resolve this problem.

Without more info I won't be able to give a more precise solution (even though this answer was made six months after the question).

Fernando Garcia
  • 141
  • 2
  • 6
0

Below is part of the solution I used to plot the notch filtered time series data on a UIAxes in app designer with the correct date and time on the axis. This is for 1000Hz data in 90 min blocks (~550 Mb ascii files) for 5 seperate channels (only showing one below).

app.Bx = app.DataLoaded(:,8); % time series data from imported text file

% set the date and time from loaded data YYYY MM DD HH MM SS MS
app.dateT = datetime(app.DataLoaded(:,1),app.DataLoaded(:,2),app.DataLoaded(:,3),app.DataLoaded(:,4),app.DataLoaded(:,5),app.DataLoaded(:,6),MilliSec);

t = 0:(size(app.Bx,1)-1);    % set the time variable from 0 to length of file
t = t/app.Frequency;         % in seconds and correct for Frequency rate 

app.Bx = detrend(app.Bx,'linear'); % removing of best straight-line fit from data
app.Bx = detrend(app.Bx,'constant'); % removes the mean value from data

FreqNotch = (app.UITable.Data);  % get the data entered in the notch table
FreqNotch = cell2mat(FreqNotch); % convert table cell to matrix

app.FilteredBx = idealfilter(app.Bx,FreqNotch,'notch'); % notch filter each

line(app.UIAxesTS1,app.dateT,(app.Bx.data),'Color',[0.27 0.87 1], 'LineWidth',0.8);

Cheers, B K

B K
  • 16
  • 3