Tag Archives: matlab
Changes in Predicted values after training
Hello Friends,
I need some help as regards predicted values from an LSTM neural netwrok that I designed. See the attached picture of the main code for the LSTM.
After training , the predicted values are always different from the previous simulation.
In the training options, I tried to set the BiasInitializer to zeros and the WeightsInitializer as well to ones but still the changes in predicted values always occur.
I will be glad if someone can guide me on this point.Hello Friends,
I need some help as regards predicted values from an LSTM neural netwrok that I designed. See the attached picture of the main code for the LSTM.
After training , the predicted values are always different from the previous simulation.
In the training options, I tried to set the BiasInitializer to zeros and the WeightsInitializer as well to ones but still the changes in predicted values always occur.
I will be glad if someone can guide me on this point. Hello Friends,
I need some help as regards predicted values from an LSTM neural netwrok that I designed. See the attached picture of the main code for the LSTM.
After training , the predicted values are always different from the previous simulation.
In the training options, I tried to set the BiasInitializer to zeros and the WeightsInitializer as well to ones but still the changes in predicted values always occur.
I will be glad if someone can guide me on this point. lstm, predict, training option MATLAB Answers — New Questions
Extended kalman filter jacobian function
I am trying to code my extended Kalman filter on a system and I know the function of the jacobian of the nonlinear output function. I read the documentation and look at the MeasurementJacobianFcn example, but I would need to pass to the function some parameters, is this possible?I am trying to code my extended Kalman filter on a system and I know the function of the jacobian of the nonlinear output function. I read the documentation and look at the MeasurementJacobianFcn example, but I would need to pass to the function some parameters, is this possible? I am trying to code my extended Kalman filter on a system and I know the function of the jacobian of the nonlinear output function. I read the documentation and look at the MeasurementJacobianFcn example, but I would need to pass to the function some parameters, is this possible? extended kalman filter, jacobian MATLAB Answers — New Questions
which MATLAB version is suitable for modelling and simulation of this topic “SENSORLESS SPEED TRACKING OF AN INDUCTION MOTOR DRIVE BASED ON
which MATLAB version is suitable for modelling and simulation of this topic "SENSORLESS SPEED TRACKING OF AN INDUCTION MOTOR DRIVE BASED ON IMPROVED X-MRAS SPEED ESTIMATORwhich MATLAB version is suitable for modelling and simulation of this topic "SENSORLESS SPEED TRACKING OF AN INDUCTION MOTOR DRIVE BASED ON IMPROVED X-MRAS SPEED ESTIMATOR which MATLAB version is suitable for modelling and simulation of this topic "SENSORLESS SPEED TRACKING OF AN INDUCTION MOTOR DRIVE BASED ON IMPROVED X-MRAS SPEED ESTIMATOR x-mras, sensorless, control, induction motor drive MATLAB Answers — New Questions
Problem with time series analysis function using detrended fluctuation analysis
Hi,
this is quite a specialized question.
I am trying to analyze a time series (standard matrix) using detrended fluctuation analysis. The script/function I am using is dfaedit (see attachment). The problem I am facing is that the results come out negative even though the results are only meant to be positive between 0-2. Hence there must be an issue with the calculation but I can not identify what it is.
Does anyone have an idea?Hi,
this is quite a specialized question.
I am trying to analyze a time series (standard matrix) using detrended fluctuation analysis. The script/function I am using is dfaedit (see attachment). The problem I am facing is that the results come out negative even though the results are only meant to be positive between 0-2. Hence there must be an issue with the calculation but I can not identify what it is.
Does anyone have an idea? Hi,
this is quite a specialized question.
I am trying to analyze a time series (standard matrix) using detrended fluctuation analysis. The script/function I am using is dfaedit (see attachment). The problem I am facing is that the results come out negative even though the results are only meant to be positive between 0-2. Hence there must be an issue with the calculation but I can not identify what it is.
Does anyone have an idea? dfa, detrended fluctuation analysis, time series MATLAB Answers — New Questions
Simulation – number of samples
MATLAB Helpcenter states:
When analyzing your FIS, you can configure the resolution of the output variable universe of discourse. To do so, set the Number of Samples parameter.
Is there a preset (optimum) value and how is this determined?MATLAB Helpcenter states:
When analyzing your FIS, you can configure the resolution of the output variable universe of discourse. To do so, set the Number of Samples parameter.
Is there a preset (optimum) value and how is this determined? MATLAB Helpcenter states:
When analyzing your FIS, you can configure the resolution of the output variable universe of discourse. To do so, set the Number of Samples parameter.
Is there a preset (optimum) value and how is this determined? fuzzy logic designer, simulation, system validation MATLAB Answers — New Questions
How to calculate Total Harmonic Distortion (THD) by using matlab code from csv file
Hello everyone,
I have .csv exported from oscilloscope and I do not know how to calculate the THD (in percentage) from this file. The fundamental frequency is 60 Hz, and the file is about sinusoidal current waveform. Thank you so much for your help.Hello everyone,
I have .csv exported from oscilloscope and I do not know how to calculate the THD (in percentage) from this file. The fundamental frequency is 60 Hz, and the file is about sinusoidal current waveform. Thank you so much for your help. Hello everyone,
I have .csv exported from oscilloscope and I do not know how to calculate the THD (in percentage) from this file. The fundamental frequency is 60 Hz, and the file is about sinusoidal current waveform. Thank you so much for your help. fft, thd MATLAB Answers — New Questions
Why do I get the error “An error occurred while attempting to shut down MATLAB.”?
When trying to shut down MATLAB so I can update it, I get the following error:
An error occurred while attempting to shut down MATLAB. For help, see this MATLAB Answer.
Why am I receiving this error?When trying to shut down MATLAB so I can update it, I get the following error:
An error occurred while attempting to shut down MATLAB. For help, see this MATLAB Answer.
Why am I receiving this error? When trying to shut down MATLAB so I can update it, I get the following error:
An error occurred while attempting to shut down MATLAB. For help, see this MATLAB Answer.
Why am I receiving this error? MATLAB Answers — New Questions
Why does OCR separate Text into Words?
Hi all,
I am trying to retrieve specific text from scanned documents reporting tables of numbers. Since the table can change in the amount of column, I use the following approach:
1 – detection of the units of measure through OCR function,
2 – from the units I need (for example, kg/kW.h), calculation of a proper region of interest where OCR function is used to retrieve the needed numbers
This works rather fine but I do not obtain a consistent behaviour of OCR function. In particular, some cases, all the units are well separated into words by OCR function while in others they are grouped together in a single word. In the code below working with the attached data sample, you can see the issue. In particular, the 16th element of txt1.Words reports the units ‘(kg/kW.h)(kW.h/)’ rather than having two Words (one for ‘(kg/kW.h)’ and the other for ‘(kW.h/)’) with their own WordBoundingBoxes. I do not understand why in some case, the units are in the same Word and in other they are bounded together in a single Word. Is it possible to control the generation process of Words in OCR function?
clear all
load(‘test.mat’)
figure
imshow(I)
roi=[250.5 526 1300 142];
Iocr=insertShape(I,’rectangle’,roi,’ShapeColor’,’blue’);
hold on
imshow(Iocr)
txt1=ocr(I,roi,CharacterSet=".()kWrpmlhgh/");%,LayoutAnalysis=’word’);
UnitString=regexp(txt1.Words,'(?<=()[w./]*(?=))’,’match’);
UnitString(cellfun(@isempty,UnitString))=[];
UnitBox=txt1.WordBoundingBoxes(not(cellfun(@isempty,UnitString)),:);Hi all,
I am trying to retrieve specific text from scanned documents reporting tables of numbers. Since the table can change in the amount of column, I use the following approach:
1 – detection of the units of measure through OCR function,
2 – from the units I need (for example, kg/kW.h), calculation of a proper region of interest where OCR function is used to retrieve the needed numbers
This works rather fine but I do not obtain a consistent behaviour of OCR function. In particular, some cases, all the units are well separated into words by OCR function while in others they are grouped together in a single word. In the code below working with the attached data sample, you can see the issue. In particular, the 16th element of txt1.Words reports the units ‘(kg/kW.h)(kW.h/)’ rather than having two Words (one for ‘(kg/kW.h)’ and the other for ‘(kW.h/)’) with their own WordBoundingBoxes. I do not understand why in some case, the units are in the same Word and in other they are bounded together in a single Word. Is it possible to control the generation process of Words in OCR function?
clear all
load(‘test.mat’)
figure
imshow(I)
roi=[250.5 526 1300 142];
Iocr=insertShape(I,’rectangle’,roi,’ShapeColor’,’blue’);
hold on
imshow(Iocr)
txt1=ocr(I,roi,CharacterSet=".()kWrpmlhgh/");%,LayoutAnalysis=’word’);
UnitString=regexp(txt1.Words,'(?<=()[w./]*(?=))’,’match’);
UnitString(cellfun(@isempty,UnitString))=[];
UnitBox=txt1.WordBoundingBoxes(not(cellfun(@isempty,UnitString)),:); Hi all,
I am trying to retrieve specific text from scanned documents reporting tables of numbers. Since the table can change in the amount of column, I use the following approach:
1 – detection of the units of measure through OCR function,
2 – from the units I need (for example, kg/kW.h), calculation of a proper region of interest where OCR function is used to retrieve the needed numbers
This works rather fine but I do not obtain a consistent behaviour of OCR function. In particular, some cases, all the units are well separated into words by OCR function while in others they are grouped together in a single word. In the code below working with the attached data sample, you can see the issue. In particular, the 16th element of txt1.Words reports the units ‘(kg/kW.h)(kW.h/)’ rather than having two Words (one for ‘(kg/kW.h)’ and the other for ‘(kW.h/)’) with their own WordBoundingBoxes. I do not understand why in some case, the units are in the same Word and in other they are bounded together in a single Word. Is it possible to control the generation process of Words in OCR function?
clear all
load(‘test.mat’)
figure
imshow(I)
roi=[250.5 526 1300 142];
Iocr=insertShape(I,’rectangle’,roi,’ShapeColor’,’blue’);
hold on
imshow(Iocr)
txt1=ocr(I,roi,CharacterSet=".()kWrpmlhgh/");%,LayoutAnalysis=’word’);
UnitString=regexp(txt1.Words,'(?<=()[w./]*(?=))’,’match’);
UnitString(cellfun(@isempty,UnitString))=[];
UnitBox=txt1.WordBoundingBoxes(not(cellfun(@isempty,UnitString)),:); ocr MATLAB Answers — New Questions
Error using thingsspeak in MATLAB
We have sensors connected on power grid lines that will tell the status wether there is any issue . We are trying to use thingsspeak and we performed some initial working which is shown in attached snap
Relevant code view is:
classdef IoTDataExplorerForThingSpeakUsingMATLAB < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
IoTDataExplorerForThingSpeakUIFigure matlab.ui.Figure
GridLayout matlab.ui.container.GridLayout
LeftPanel matlab.ui.container.Panel
F4CheckBox matlab.ui.control.CheckBox
ReadAPIKeyEditField matlab.ui.control.EditField
ReadAPIKeyEditFieldLabel matlab.ui.control.Label
ChannelIDEditField matlab.ui.control.NumericEditField
ChannelIDEditFieldLabel matlab.ui.control.Label
RightPanel matlab.ui.container.Panel
StatusLabel matlab.ui.control.Label
end
% Properties that correspond to apps with auto-reflow
properties (Access = private)
onePanelWidth = 576;
end
% Copyright 2020 – 2020 The MathWorks, Inc.
properties (Access = private)
legendLabel1
legendLabel2
myChans
end
methods (Access = private)
function displayFields=enumerateSelectedFields(app)
% Create array of the fields for processing
displayFields = [app.F4CheckBox.Value];
end
end
methods (Access = private)
function [query] = buildQueryFromInputs(app)
% buildQueryFromInputs build the querry inputs into a struct.
% q = buildQueryFromInputs(app)
%is a list of inputs needed to
% get the appropriate data from ThingSpeak.
% The data includes the start and stop date, channel ID and API keys.
%
query = struct();
% queryRecent = struct();
% queryOld = struct();
app.StatusLabel.Text = ‘Status’;
query.APIKey = app.ReadAPIKeyEditField.Value;
query.channelID = app.ChannelIDEditField.Value;
%query.startHour = hours(str2double(app.StartHourDropDown.Value));
%query.startMinute = minutes(str2double(app.MinDropDown.Value));
% query.dmult = app.plotDuration.Value;
%query.lmult = app.plotLengthofComparison.Value;
% build the start date with date, minutes, hours and am/PM
% queryRecent.startDate = app.StartDateDatePicker.Value + …
% query.startHour + query.startMinute;
% if app.AMPMSwitch.Value == "PM"
% queryRecent.startDate = queryRecent.startDate + hours(12);
% end
%queryRecent.endDate = queryRecent.startDate + getCompareDuration(app);
%query.fieldsList = {};
%queryDisplayFields = enumerateSelectedFields(app);
% build the fields list for ThingSpeak Read
% for i= 1:8
% if queryDisplayFields(i) > 0
% query.fieldsList = [query.fieldsList, i];
% end
% end
% query.fieldsList = cell2mat(query.fieldsList);
% queryOld.startDate = queryRecent.startDate – getCompareWidth(app);
% queryOld.endDate = queryOld.startDate + getCompareDuration(app);
% end
% function myData = getDataFromQuery(app, query,queryStartEnd)
% getDataFromQueryRecent() get the recent data.
% data = getDataFromQueryRecent(app, queryRecent) is a the
% most recent data. Requires buildQueryFromInputs to get
% startDate, endDate, fieldsList, channelID, and APIKey.
%
% try
% myData = thingSpeakRead(query.channelID, …
% ‘ReadKey’, query.APIKey, …
% ‘DateRange’,[queryStartEnd.startDate queryStartEnd.endDate], …
% ‘Fields’, query.fieldsList, …
% ‘OutputFormat’,’Timetable’);
% catch readingError
% myData = timetable();
% uialert(app.IoTDataExplorerForThingSpeakUIFigure,readingError.identifier,"Data error for that time interval");
% return
% end
% if isempty(myData)
% uialert(app.IoTDataExplorerForThingSpeakUIFigure,"No Data for that time interval","Pick some different data");
% myData = timetable();
% return
% end
% if height(myData) >= 8000
% app.StatusLabel.Text = "Read limit reached. Duration may be shorter than expected";
% end
% Use retime if the user has selected that option
% if app.RetimeDropDown.Value ~= "Raw"
% myData = retime(myData,app.RetimeDropDown.Value,’linear’);
% end
% end
% function visualizeData(app,recentData, oldData, queryInfo)
% visualizeData() display the data.
% visualizeData(app,recentData, oldData) uses a the recentData and oldData to
% plot the data in a tiled layot depending on the number of
% fields selected.
% dataDisplayFields = enumerateSelectedFields(app);
% if sum(dataDisplayFields) > width(oldData)
% uialert(app.IoTDataExplorerForThingSpeakUIFigure,"Not enough Fields selected","Pick a different channel or different fields.");
% end
% Check to make sure the earlier functions produced data.
% if width(recentData) == 0
% return
% end
% if width(oldData) == 0
% return
% end
% t = tiledlayout(app.RightPanel,sum(dataDisplayFields),1,’tilespacing’,’none’);
% Change data to elapsed time
% elapsedRecent = recentData.Timestamps – recentData.Timestamps(1) + …
% queryInfo.startHour + queryInfo.startMinute;
% elapsedOld = oldData.Timestamps-oldData.Timestamps(1) + …
% queryInfo.startHour + queryInfo.startMinute;
% Determine which set is shortest.
% minLength = min(height(oldData),height(recentData));
% myTile = 0;
% for index = 1:8
% if dataDisplayFields(index)>0
% myTile = myTile + 1;
% myAxes = nexttile(t);
% plotVar = recentData.(myTile);
% plot(myAxes,elapsedRecent(1:minLength),plotVar(1:minLength),’-o’,’MarkerSize’,2); %#<ADMTHDINV>
% if app.CompareLengthDropDown.Value ~= minutes(0) % minutes(0) is the setting for don’t show the old data
% hold(myAxes,"on");
% plotVar2=oldData.(myTile);
% plot(myAxes,elapsedOld(1:minLength),plotVar2(1:minLength),’-*’,’MarkerSize’,2);
% end
% title(myAxes,recentData.Properties.VariableNames(myTile));
% if myTile > 1
% set (myAxes,’xtick’,[]);
% legend(myAxes,["Recent" ,"Old"]);
% else
% legend(myAxes,{app.legendLabel1, app.legendLabel2});
% end
% end
% end
% end
% function compareDuration = getCompareDuration(app)
% % Determine the length in time of the data analysis for each
% window from the GUI inputs.
% dmult = app.plotDuration.Value;
% compareDuration = app.DurationDropDown.Value * dmult;
% end
% function legendLabel = getLegendLabel(app,startDate)
% Format the legendLabel based on the start data and duration
% selected.
% dmult = app.plotDuration.Value;
% switch app.DurationDropDown.Value
% case minutes(1)
% legendLabel = string(dmult) + ‘ Minutes on ‘ + string(startDate);
% case hours(1)
% legendLabel = string(dmult) + ‘ Hours on ‘ + string(startDate);
% case hours(24)
% legendLabel = string(dmult) + ‘ Days on ‘ + string(startDate);
% case days(7)
% legendLabel = string(dmult) + ‘ Weeks on ‘ + string(startDate);
% case days(365)
% legendLabel = string(dmult) + ‘ Years on ‘ + string(startDate);
% end
% if app.RetimeDropDown.Value ~= "Raw"
% legendLabel = legendLabel + " " + string(app.RetimeDropDown.Value);
% end
% end
% function compareWidth = getCompareWidth(app)
% Determine the difference in time from the recent data to the
% older data from the GUI inputs.
% lmult = app.plotLengthofComparison.Value;
% compareWidth = app.CompareLengthDropDown.Value * lmult;
% end
% end
% Callbacks that handle component events
methods (Access = private)
% Changes arrangement of the app based on UIFigure width
function updateAppLayout(app, event)
currentFigureWidth = app.IoTDataExplorerForThingSpeakUIFigure.Position(3);
if(currentFigureWidth <= app.onePanelWidth)
% Change to a 2×1 grid
app.GridLayout.RowHeight = {511, 511};
app.GridLayout.ColumnWidth = {‘1x’};
app.RightPanel.Layout.Row = 2;
app.RightPanel.Layout.Column = 1;
else
% Change to a 1×2 grid
app.GridLayout.RowHeight = {‘1x’};
app.GridLayout.ColumnWidth = {241, ‘1x’};
app.RightPanel.Layout.Row = 1;
app.RightPanel.Layout.Column = 2;
end
end
% Value changed function: F4CheckBox
function F4CheckBoxValueChanged(app, event)
value = app.F4CheckBox.value;
end
end
% Value changed function: ChannelIDEditField
function ChannelIDEditFieldValueChanged(app, event)
value = app.ChannelIDEditField.Value;
end
% Value changed function: ReadAPIKeyEditField
function ReadAPIKeyEditFieldValueChanged(app, event)
value = app.ReadAPIKeyEditField.Value;
end
end
% Component initialization
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Create IoTDataExplorerForThingSpeakUIFigure and hide until all components are created
app.IoTDataExplorerForThingSpeakUIFigure = uifigure(‘Visible’, ‘off’);
app.IoTDataExplorerForThingSpeakUIFigure.AutoResizeChildren = ‘off’;
app.IoTDataExplorerForThingSpeakUIFigure.Position = [100 100 710 511];
app.IoTDataExplorerForThingSpeakUIFigure.Name = ‘ThingSpeak Data Explorer’;
app.IoTDataExplorerForThingSpeakUIFigure.SizeChangedFcn = createCallbackFcn(app, @updateAppLayout, true);
% Create GridLayout
app.GridLayout = uigridlayout(app.IoTDataExplorerForThingSpeakUIFigure);
app.GridLayout.ColumnWidth = {241, ‘1x’};
app.GridLayout.RowHeight = {‘1x’};
app.GridLayout.ColumnSpacing = 0;
app.GridLayout.RowSpacing = 0;
app.GridLayout.Padding = [0 0 0 0];
app.GridLayout.Scrollable = ‘on’;
% Create LeftPanel
app.LeftPanel = uipanel(app.GridLayout);
app.LeftPanel.Layout.Row = 1;
app.LeftPanel.Layout.Column = 1;
% Create ChannelIDEditFieldLabel
app.ChannelIDEditFieldLabel = uilabel(app.LeftPanel);
app.ChannelIDEditFieldLabel.HorizontalAlignment = ‘right’;
app.ChannelIDEditFieldLabel.Position = [12 464 66 22];
app.ChannelIDEditFieldLabel.Text = ‘Channel ID’;
% Create ChannelIDEditField
app.ChannelIDEditField = uieditfield(app.LeftPanel, ‘numeric’);
app.ChannelIDEditField.ValueDisplayFormat = ‘%.0f’;
app.ChannelIDEditField.ValueChangedFcn = createCallbackFcn(app, @ChannelIDEditFieldValueChanged, true);
app.ChannelIDEditField.Position = [93 464 55 22];
app.ChannelIDEditField.Value = 543172;
% Create ReadAPIKeyEditFieldLabel
app.ReadAPIKeyEditFieldLabel = uilabel(app.LeftPanel);
app.ReadAPIKeyEditFieldLabel.HorizontalAlignment = ‘right’;
app.ReadAPIKeyEditFieldLabel.Position = [13 434 74 22];
app.ReadAPIKeyEditFieldLabel.Text = ‘ReadAPIKey’;
% Create ReadAPIKeyEditField
app.ReadAPIKeyEditField = uieditfield(app.LeftPanel, ‘text’);
app.ReadAPIKeyEditField.ValueChangedFcn = createCallbackFcn(app, @ReadAPIKeyEditFieldValueChanged, true);
app.ReadAPIKeyEditField.Position = [102 434 100 22];
app.ReadAPIKeyEditField.Value = ‘0BXYOJW16B7R6DMM’;
% Create F4CheckBox
app.F4CheckBox = uicheckbox(app.LeftPanel);
app.F4CheckBox.ValueChangedFcn = createCallbackFcn(app, @F4CheckBoxValueChanged, true);
app.F4CheckBox.Text = ‘F4’;
app.F4CheckBox.Position = [14 178 36 22];
app.F4CheckBox.Value = true;
% Create RightPanel
app.RightPanel = uipanel(app.GridLayout);
app.RightPanel.Layout.Row = 1;
app.RightPanel.Layout.Column = 2;
% Create StatusLabel
app.StatusLabel = uilabel(app.RightPanel);
app.StatusLabel.Position = [2 1 449 22];
app.StatusLabel.Text = ‘Status’;
% Show the figure after all components are created
app.IoTDataExplorerForThingSpeakUIFigure.Visible = ‘on’;
end
end
% App creation and deletion
methods (Access = public)
% Construct app
function app = IoTDataExplorerForThingSpeakUsingMATLAB
% Create UIFigure and components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.IoTDataExplorerForThingSpeakUIFigure)
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.IoTDataExplorerForThingSpeakUIFigure)
end
end
end
But when we try to run ,we get error:
Unrecognized function or variable ‘updateAppLayout’.
Error in matlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event) (line 62)
newCallback = @(source, event)executeCallback(ams, …
Error using IoTDataExplorerForThingSpeakUsingMATLAB/createComponents (line 324)
Error while evaluating Figure SizeChangedFcn.
Warning: The following error was caught while executing ‘onCleanup’ class destructor:
Brace indexing is not supported for variables of this type.
Error in cell2mat (line 36)
if isnumeric(c{1}) || ischar(c{1}) || islogical(c{1}) || isstruct(c{1})
Error in onCleanup/delete (line 25)
obj.task();
Warning: The following error was caught while executing ‘onCleanup’ class destructor:
Brace indexing is not supported for variables of this type.
Error in cell2mat (line 36)
if isnumeric(c{1}) || ischar(c{1}) || islogical(c{1}) || isstruct(c{1})
Error in onCleanup/delete (line 25)
obj.task();
Error in onCleanup/delete (line 25)
obj.task();
Error inmatlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event)
(line 62)
newCallback = @(source, event)executeCallback(ams, … > In onCleanup/delete (line 25)
In matlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event) (line 62)
In matlab.ui.internal.controller/FigureController/handleClientEvent (line 832)
In matlab.ui.internal.controller/FigureController/handleEvent (line 667)
In matlab.ui.internal.controller.WebCanvasContainerController>@(varargin)this.handleEvent(varargin{:}) (line 45)
Unrecognized function or variable ‘updateAppLayout’.
Error in matlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event) (line 62)
newCallback = @(source, event)executeCallback(ams, …
Error using matlab.ui.internal.controller.FigureController/handleClientEvent (line 832)
Error while evaluating Figure SizeChangedFcn.
>>We have sensors connected on power grid lines that will tell the status wether there is any issue . We are trying to use thingsspeak and we performed some initial working which is shown in attached snap
Relevant code view is:
classdef IoTDataExplorerForThingSpeakUsingMATLAB < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
IoTDataExplorerForThingSpeakUIFigure matlab.ui.Figure
GridLayout matlab.ui.container.GridLayout
LeftPanel matlab.ui.container.Panel
F4CheckBox matlab.ui.control.CheckBox
ReadAPIKeyEditField matlab.ui.control.EditField
ReadAPIKeyEditFieldLabel matlab.ui.control.Label
ChannelIDEditField matlab.ui.control.NumericEditField
ChannelIDEditFieldLabel matlab.ui.control.Label
RightPanel matlab.ui.container.Panel
StatusLabel matlab.ui.control.Label
end
% Properties that correspond to apps with auto-reflow
properties (Access = private)
onePanelWidth = 576;
end
% Copyright 2020 – 2020 The MathWorks, Inc.
properties (Access = private)
legendLabel1
legendLabel2
myChans
end
methods (Access = private)
function displayFields=enumerateSelectedFields(app)
% Create array of the fields for processing
displayFields = [app.F4CheckBox.Value];
end
end
methods (Access = private)
function [query] = buildQueryFromInputs(app)
% buildQueryFromInputs build the querry inputs into a struct.
% q = buildQueryFromInputs(app)
%is a list of inputs needed to
% get the appropriate data from ThingSpeak.
% The data includes the start and stop date, channel ID and API keys.
%
query = struct();
% queryRecent = struct();
% queryOld = struct();
app.StatusLabel.Text = ‘Status’;
query.APIKey = app.ReadAPIKeyEditField.Value;
query.channelID = app.ChannelIDEditField.Value;
%query.startHour = hours(str2double(app.StartHourDropDown.Value));
%query.startMinute = minutes(str2double(app.MinDropDown.Value));
% query.dmult = app.plotDuration.Value;
%query.lmult = app.plotLengthofComparison.Value;
% build the start date with date, minutes, hours and am/PM
% queryRecent.startDate = app.StartDateDatePicker.Value + …
% query.startHour + query.startMinute;
% if app.AMPMSwitch.Value == "PM"
% queryRecent.startDate = queryRecent.startDate + hours(12);
% end
%queryRecent.endDate = queryRecent.startDate + getCompareDuration(app);
%query.fieldsList = {};
%queryDisplayFields = enumerateSelectedFields(app);
% build the fields list for ThingSpeak Read
% for i= 1:8
% if queryDisplayFields(i) > 0
% query.fieldsList = [query.fieldsList, i];
% end
% end
% query.fieldsList = cell2mat(query.fieldsList);
% queryOld.startDate = queryRecent.startDate – getCompareWidth(app);
% queryOld.endDate = queryOld.startDate + getCompareDuration(app);
% end
% function myData = getDataFromQuery(app, query,queryStartEnd)
% getDataFromQueryRecent() get the recent data.
% data = getDataFromQueryRecent(app, queryRecent) is a the
% most recent data. Requires buildQueryFromInputs to get
% startDate, endDate, fieldsList, channelID, and APIKey.
%
% try
% myData = thingSpeakRead(query.channelID, …
% ‘ReadKey’, query.APIKey, …
% ‘DateRange’,[queryStartEnd.startDate queryStartEnd.endDate], …
% ‘Fields’, query.fieldsList, …
% ‘OutputFormat’,’Timetable’);
% catch readingError
% myData = timetable();
% uialert(app.IoTDataExplorerForThingSpeakUIFigure,readingError.identifier,"Data error for that time interval");
% return
% end
% if isempty(myData)
% uialert(app.IoTDataExplorerForThingSpeakUIFigure,"No Data for that time interval","Pick some different data");
% myData = timetable();
% return
% end
% if height(myData) >= 8000
% app.StatusLabel.Text = "Read limit reached. Duration may be shorter than expected";
% end
% Use retime if the user has selected that option
% if app.RetimeDropDown.Value ~= "Raw"
% myData = retime(myData,app.RetimeDropDown.Value,’linear’);
% end
% end
% function visualizeData(app,recentData, oldData, queryInfo)
% visualizeData() display the data.
% visualizeData(app,recentData, oldData) uses a the recentData and oldData to
% plot the data in a tiled layot depending on the number of
% fields selected.
% dataDisplayFields = enumerateSelectedFields(app);
% if sum(dataDisplayFields) > width(oldData)
% uialert(app.IoTDataExplorerForThingSpeakUIFigure,"Not enough Fields selected","Pick a different channel or different fields.");
% end
% Check to make sure the earlier functions produced data.
% if width(recentData) == 0
% return
% end
% if width(oldData) == 0
% return
% end
% t = tiledlayout(app.RightPanel,sum(dataDisplayFields),1,’tilespacing’,’none’);
% Change data to elapsed time
% elapsedRecent = recentData.Timestamps – recentData.Timestamps(1) + …
% queryInfo.startHour + queryInfo.startMinute;
% elapsedOld = oldData.Timestamps-oldData.Timestamps(1) + …
% queryInfo.startHour + queryInfo.startMinute;
% Determine which set is shortest.
% minLength = min(height(oldData),height(recentData));
% myTile = 0;
% for index = 1:8
% if dataDisplayFields(index)>0
% myTile = myTile + 1;
% myAxes = nexttile(t);
% plotVar = recentData.(myTile);
% plot(myAxes,elapsedRecent(1:minLength),plotVar(1:minLength),’-o’,’MarkerSize’,2); %#<ADMTHDINV>
% if app.CompareLengthDropDown.Value ~= minutes(0) % minutes(0) is the setting for don’t show the old data
% hold(myAxes,"on");
% plotVar2=oldData.(myTile);
% plot(myAxes,elapsedOld(1:minLength),plotVar2(1:minLength),’-*’,’MarkerSize’,2);
% end
% title(myAxes,recentData.Properties.VariableNames(myTile));
% if myTile > 1
% set (myAxes,’xtick’,[]);
% legend(myAxes,["Recent" ,"Old"]);
% else
% legend(myAxes,{app.legendLabel1, app.legendLabel2});
% end
% end
% end
% end
% function compareDuration = getCompareDuration(app)
% % Determine the length in time of the data analysis for each
% window from the GUI inputs.
% dmult = app.plotDuration.Value;
% compareDuration = app.DurationDropDown.Value * dmult;
% end
% function legendLabel = getLegendLabel(app,startDate)
% Format the legendLabel based on the start data and duration
% selected.
% dmult = app.plotDuration.Value;
% switch app.DurationDropDown.Value
% case minutes(1)
% legendLabel = string(dmult) + ‘ Minutes on ‘ + string(startDate);
% case hours(1)
% legendLabel = string(dmult) + ‘ Hours on ‘ + string(startDate);
% case hours(24)
% legendLabel = string(dmult) + ‘ Days on ‘ + string(startDate);
% case days(7)
% legendLabel = string(dmult) + ‘ Weeks on ‘ + string(startDate);
% case days(365)
% legendLabel = string(dmult) + ‘ Years on ‘ + string(startDate);
% end
% if app.RetimeDropDown.Value ~= "Raw"
% legendLabel = legendLabel + " " + string(app.RetimeDropDown.Value);
% end
% end
% function compareWidth = getCompareWidth(app)
% Determine the difference in time from the recent data to the
% older data from the GUI inputs.
% lmult = app.plotLengthofComparison.Value;
% compareWidth = app.CompareLengthDropDown.Value * lmult;
% end
% end
% Callbacks that handle component events
methods (Access = private)
% Changes arrangement of the app based on UIFigure width
function updateAppLayout(app, event)
currentFigureWidth = app.IoTDataExplorerForThingSpeakUIFigure.Position(3);
if(currentFigureWidth <= app.onePanelWidth)
% Change to a 2×1 grid
app.GridLayout.RowHeight = {511, 511};
app.GridLayout.ColumnWidth = {‘1x’};
app.RightPanel.Layout.Row = 2;
app.RightPanel.Layout.Column = 1;
else
% Change to a 1×2 grid
app.GridLayout.RowHeight = {‘1x’};
app.GridLayout.ColumnWidth = {241, ‘1x’};
app.RightPanel.Layout.Row = 1;
app.RightPanel.Layout.Column = 2;
end
end
% Value changed function: F4CheckBox
function F4CheckBoxValueChanged(app, event)
value = app.F4CheckBox.value;
end
end
% Value changed function: ChannelIDEditField
function ChannelIDEditFieldValueChanged(app, event)
value = app.ChannelIDEditField.Value;
end
% Value changed function: ReadAPIKeyEditField
function ReadAPIKeyEditFieldValueChanged(app, event)
value = app.ReadAPIKeyEditField.Value;
end
end
% Component initialization
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Create IoTDataExplorerForThingSpeakUIFigure and hide until all components are created
app.IoTDataExplorerForThingSpeakUIFigure = uifigure(‘Visible’, ‘off’);
app.IoTDataExplorerForThingSpeakUIFigure.AutoResizeChildren = ‘off’;
app.IoTDataExplorerForThingSpeakUIFigure.Position = [100 100 710 511];
app.IoTDataExplorerForThingSpeakUIFigure.Name = ‘ThingSpeak Data Explorer’;
app.IoTDataExplorerForThingSpeakUIFigure.SizeChangedFcn = createCallbackFcn(app, @updateAppLayout, true);
% Create GridLayout
app.GridLayout = uigridlayout(app.IoTDataExplorerForThingSpeakUIFigure);
app.GridLayout.ColumnWidth = {241, ‘1x’};
app.GridLayout.RowHeight = {‘1x’};
app.GridLayout.ColumnSpacing = 0;
app.GridLayout.RowSpacing = 0;
app.GridLayout.Padding = [0 0 0 0];
app.GridLayout.Scrollable = ‘on’;
% Create LeftPanel
app.LeftPanel = uipanel(app.GridLayout);
app.LeftPanel.Layout.Row = 1;
app.LeftPanel.Layout.Column = 1;
% Create ChannelIDEditFieldLabel
app.ChannelIDEditFieldLabel = uilabel(app.LeftPanel);
app.ChannelIDEditFieldLabel.HorizontalAlignment = ‘right’;
app.ChannelIDEditFieldLabel.Position = [12 464 66 22];
app.ChannelIDEditFieldLabel.Text = ‘Channel ID’;
% Create ChannelIDEditField
app.ChannelIDEditField = uieditfield(app.LeftPanel, ‘numeric’);
app.ChannelIDEditField.ValueDisplayFormat = ‘%.0f’;
app.ChannelIDEditField.ValueChangedFcn = createCallbackFcn(app, @ChannelIDEditFieldValueChanged, true);
app.ChannelIDEditField.Position = [93 464 55 22];
app.ChannelIDEditField.Value = 543172;
% Create ReadAPIKeyEditFieldLabel
app.ReadAPIKeyEditFieldLabel = uilabel(app.LeftPanel);
app.ReadAPIKeyEditFieldLabel.HorizontalAlignment = ‘right’;
app.ReadAPIKeyEditFieldLabel.Position = [13 434 74 22];
app.ReadAPIKeyEditFieldLabel.Text = ‘ReadAPIKey’;
% Create ReadAPIKeyEditField
app.ReadAPIKeyEditField = uieditfield(app.LeftPanel, ‘text’);
app.ReadAPIKeyEditField.ValueChangedFcn = createCallbackFcn(app, @ReadAPIKeyEditFieldValueChanged, true);
app.ReadAPIKeyEditField.Position = [102 434 100 22];
app.ReadAPIKeyEditField.Value = ‘0BXYOJW16B7R6DMM’;
% Create F4CheckBox
app.F4CheckBox = uicheckbox(app.LeftPanel);
app.F4CheckBox.ValueChangedFcn = createCallbackFcn(app, @F4CheckBoxValueChanged, true);
app.F4CheckBox.Text = ‘F4’;
app.F4CheckBox.Position = [14 178 36 22];
app.F4CheckBox.Value = true;
% Create RightPanel
app.RightPanel = uipanel(app.GridLayout);
app.RightPanel.Layout.Row = 1;
app.RightPanel.Layout.Column = 2;
% Create StatusLabel
app.StatusLabel = uilabel(app.RightPanel);
app.StatusLabel.Position = [2 1 449 22];
app.StatusLabel.Text = ‘Status’;
% Show the figure after all components are created
app.IoTDataExplorerForThingSpeakUIFigure.Visible = ‘on’;
end
end
% App creation and deletion
methods (Access = public)
% Construct app
function app = IoTDataExplorerForThingSpeakUsingMATLAB
% Create UIFigure and components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.IoTDataExplorerForThingSpeakUIFigure)
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.IoTDataExplorerForThingSpeakUIFigure)
end
end
end
But when we try to run ,we get error:
Unrecognized function or variable ‘updateAppLayout’.
Error in matlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event) (line 62)
newCallback = @(source, event)executeCallback(ams, …
Error using IoTDataExplorerForThingSpeakUsingMATLAB/createComponents (line 324)
Error while evaluating Figure SizeChangedFcn.
Warning: The following error was caught while executing ‘onCleanup’ class destructor:
Brace indexing is not supported for variables of this type.
Error in cell2mat (line 36)
if isnumeric(c{1}) || ischar(c{1}) || islogical(c{1}) || isstruct(c{1})
Error in onCleanup/delete (line 25)
obj.task();
Warning: The following error was caught while executing ‘onCleanup’ class destructor:
Brace indexing is not supported for variables of this type.
Error in cell2mat (line 36)
if isnumeric(c{1}) || ischar(c{1}) || islogical(c{1}) || isstruct(c{1})
Error in onCleanup/delete (line 25)
obj.task();
Error in onCleanup/delete (line 25)
obj.task();
Error inmatlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event)
(line 62)
newCallback = @(source, event)executeCallback(ams, … > In onCleanup/delete (line 25)
In matlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event) (line 62)
In matlab.ui.internal.controller/FigureController/handleClientEvent (line 832)
In matlab.ui.internal.controller/FigureController/handleEvent (line 667)
In matlab.ui.internal.controller.WebCanvasContainerController>@(varargin)this.handleEvent(varargin{:}) (line 45)
Unrecognized function or variable ‘updateAppLayout’.
Error in matlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event) (line 62)
newCallback = @(source, event)executeCallback(ams, …
Error using matlab.ui.internal.controller.FigureController/handleClientEvent (line 832)
Error while evaluating Figure SizeChangedFcn.
>> We have sensors connected on power grid lines that will tell the status wether there is any issue . We are trying to use thingsspeak and we performed some initial working which is shown in attached snap
Relevant code view is:
classdef IoTDataExplorerForThingSpeakUsingMATLAB < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
IoTDataExplorerForThingSpeakUIFigure matlab.ui.Figure
GridLayout matlab.ui.container.GridLayout
LeftPanel matlab.ui.container.Panel
F4CheckBox matlab.ui.control.CheckBox
ReadAPIKeyEditField matlab.ui.control.EditField
ReadAPIKeyEditFieldLabel matlab.ui.control.Label
ChannelIDEditField matlab.ui.control.NumericEditField
ChannelIDEditFieldLabel matlab.ui.control.Label
RightPanel matlab.ui.container.Panel
StatusLabel matlab.ui.control.Label
end
% Properties that correspond to apps with auto-reflow
properties (Access = private)
onePanelWidth = 576;
end
% Copyright 2020 – 2020 The MathWorks, Inc.
properties (Access = private)
legendLabel1
legendLabel2
myChans
end
methods (Access = private)
function displayFields=enumerateSelectedFields(app)
% Create array of the fields for processing
displayFields = [app.F4CheckBox.Value];
end
end
methods (Access = private)
function [query] = buildQueryFromInputs(app)
% buildQueryFromInputs build the querry inputs into a struct.
% q = buildQueryFromInputs(app)
%is a list of inputs needed to
% get the appropriate data from ThingSpeak.
% The data includes the start and stop date, channel ID and API keys.
%
query = struct();
% queryRecent = struct();
% queryOld = struct();
app.StatusLabel.Text = ‘Status’;
query.APIKey = app.ReadAPIKeyEditField.Value;
query.channelID = app.ChannelIDEditField.Value;
%query.startHour = hours(str2double(app.StartHourDropDown.Value));
%query.startMinute = minutes(str2double(app.MinDropDown.Value));
% query.dmult = app.plotDuration.Value;
%query.lmult = app.plotLengthofComparison.Value;
% build the start date with date, minutes, hours and am/PM
% queryRecent.startDate = app.StartDateDatePicker.Value + …
% query.startHour + query.startMinute;
% if app.AMPMSwitch.Value == "PM"
% queryRecent.startDate = queryRecent.startDate + hours(12);
% end
%queryRecent.endDate = queryRecent.startDate + getCompareDuration(app);
%query.fieldsList = {};
%queryDisplayFields = enumerateSelectedFields(app);
% build the fields list for ThingSpeak Read
% for i= 1:8
% if queryDisplayFields(i) > 0
% query.fieldsList = [query.fieldsList, i];
% end
% end
% query.fieldsList = cell2mat(query.fieldsList);
% queryOld.startDate = queryRecent.startDate – getCompareWidth(app);
% queryOld.endDate = queryOld.startDate + getCompareDuration(app);
% end
% function myData = getDataFromQuery(app, query,queryStartEnd)
% getDataFromQueryRecent() get the recent data.
% data = getDataFromQueryRecent(app, queryRecent) is a the
% most recent data. Requires buildQueryFromInputs to get
% startDate, endDate, fieldsList, channelID, and APIKey.
%
% try
% myData = thingSpeakRead(query.channelID, …
% ‘ReadKey’, query.APIKey, …
% ‘DateRange’,[queryStartEnd.startDate queryStartEnd.endDate], …
% ‘Fields’, query.fieldsList, …
% ‘OutputFormat’,’Timetable’);
% catch readingError
% myData = timetable();
% uialert(app.IoTDataExplorerForThingSpeakUIFigure,readingError.identifier,"Data error for that time interval");
% return
% end
% if isempty(myData)
% uialert(app.IoTDataExplorerForThingSpeakUIFigure,"No Data for that time interval","Pick some different data");
% myData = timetable();
% return
% end
% if height(myData) >= 8000
% app.StatusLabel.Text = "Read limit reached. Duration may be shorter than expected";
% end
% Use retime if the user has selected that option
% if app.RetimeDropDown.Value ~= "Raw"
% myData = retime(myData,app.RetimeDropDown.Value,’linear’);
% end
% end
% function visualizeData(app,recentData, oldData, queryInfo)
% visualizeData() display the data.
% visualizeData(app,recentData, oldData) uses a the recentData and oldData to
% plot the data in a tiled layot depending on the number of
% fields selected.
% dataDisplayFields = enumerateSelectedFields(app);
% if sum(dataDisplayFields) > width(oldData)
% uialert(app.IoTDataExplorerForThingSpeakUIFigure,"Not enough Fields selected","Pick a different channel or different fields.");
% end
% Check to make sure the earlier functions produced data.
% if width(recentData) == 0
% return
% end
% if width(oldData) == 0
% return
% end
% t = tiledlayout(app.RightPanel,sum(dataDisplayFields),1,’tilespacing’,’none’);
% Change data to elapsed time
% elapsedRecent = recentData.Timestamps – recentData.Timestamps(1) + …
% queryInfo.startHour + queryInfo.startMinute;
% elapsedOld = oldData.Timestamps-oldData.Timestamps(1) + …
% queryInfo.startHour + queryInfo.startMinute;
% Determine which set is shortest.
% minLength = min(height(oldData),height(recentData));
% myTile = 0;
% for index = 1:8
% if dataDisplayFields(index)>0
% myTile = myTile + 1;
% myAxes = nexttile(t);
% plotVar = recentData.(myTile);
% plot(myAxes,elapsedRecent(1:minLength),plotVar(1:minLength),’-o’,’MarkerSize’,2); %#<ADMTHDINV>
% if app.CompareLengthDropDown.Value ~= minutes(0) % minutes(0) is the setting for don’t show the old data
% hold(myAxes,"on");
% plotVar2=oldData.(myTile);
% plot(myAxes,elapsedOld(1:minLength),plotVar2(1:minLength),’-*’,’MarkerSize’,2);
% end
% title(myAxes,recentData.Properties.VariableNames(myTile));
% if myTile > 1
% set (myAxes,’xtick’,[]);
% legend(myAxes,["Recent" ,"Old"]);
% else
% legend(myAxes,{app.legendLabel1, app.legendLabel2});
% end
% end
% end
% end
% function compareDuration = getCompareDuration(app)
% % Determine the length in time of the data analysis for each
% window from the GUI inputs.
% dmult = app.plotDuration.Value;
% compareDuration = app.DurationDropDown.Value * dmult;
% end
% function legendLabel = getLegendLabel(app,startDate)
% Format the legendLabel based on the start data and duration
% selected.
% dmult = app.plotDuration.Value;
% switch app.DurationDropDown.Value
% case minutes(1)
% legendLabel = string(dmult) + ‘ Minutes on ‘ + string(startDate);
% case hours(1)
% legendLabel = string(dmult) + ‘ Hours on ‘ + string(startDate);
% case hours(24)
% legendLabel = string(dmult) + ‘ Days on ‘ + string(startDate);
% case days(7)
% legendLabel = string(dmult) + ‘ Weeks on ‘ + string(startDate);
% case days(365)
% legendLabel = string(dmult) + ‘ Years on ‘ + string(startDate);
% end
% if app.RetimeDropDown.Value ~= "Raw"
% legendLabel = legendLabel + " " + string(app.RetimeDropDown.Value);
% end
% end
% function compareWidth = getCompareWidth(app)
% Determine the difference in time from the recent data to the
% older data from the GUI inputs.
% lmult = app.plotLengthofComparison.Value;
% compareWidth = app.CompareLengthDropDown.Value * lmult;
% end
% end
% Callbacks that handle component events
methods (Access = private)
% Changes arrangement of the app based on UIFigure width
function updateAppLayout(app, event)
currentFigureWidth = app.IoTDataExplorerForThingSpeakUIFigure.Position(3);
if(currentFigureWidth <= app.onePanelWidth)
% Change to a 2×1 grid
app.GridLayout.RowHeight = {511, 511};
app.GridLayout.ColumnWidth = {‘1x’};
app.RightPanel.Layout.Row = 2;
app.RightPanel.Layout.Column = 1;
else
% Change to a 1×2 grid
app.GridLayout.RowHeight = {‘1x’};
app.GridLayout.ColumnWidth = {241, ‘1x’};
app.RightPanel.Layout.Row = 1;
app.RightPanel.Layout.Column = 2;
end
end
% Value changed function: F4CheckBox
function F4CheckBoxValueChanged(app, event)
value = app.F4CheckBox.value;
end
end
% Value changed function: ChannelIDEditField
function ChannelIDEditFieldValueChanged(app, event)
value = app.ChannelIDEditField.Value;
end
% Value changed function: ReadAPIKeyEditField
function ReadAPIKeyEditFieldValueChanged(app, event)
value = app.ReadAPIKeyEditField.Value;
end
end
% Component initialization
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Create IoTDataExplorerForThingSpeakUIFigure and hide until all components are created
app.IoTDataExplorerForThingSpeakUIFigure = uifigure(‘Visible’, ‘off’);
app.IoTDataExplorerForThingSpeakUIFigure.AutoResizeChildren = ‘off’;
app.IoTDataExplorerForThingSpeakUIFigure.Position = [100 100 710 511];
app.IoTDataExplorerForThingSpeakUIFigure.Name = ‘ThingSpeak Data Explorer’;
app.IoTDataExplorerForThingSpeakUIFigure.SizeChangedFcn = createCallbackFcn(app, @updateAppLayout, true);
% Create GridLayout
app.GridLayout = uigridlayout(app.IoTDataExplorerForThingSpeakUIFigure);
app.GridLayout.ColumnWidth = {241, ‘1x’};
app.GridLayout.RowHeight = {‘1x’};
app.GridLayout.ColumnSpacing = 0;
app.GridLayout.RowSpacing = 0;
app.GridLayout.Padding = [0 0 0 0];
app.GridLayout.Scrollable = ‘on’;
% Create LeftPanel
app.LeftPanel = uipanel(app.GridLayout);
app.LeftPanel.Layout.Row = 1;
app.LeftPanel.Layout.Column = 1;
% Create ChannelIDEditFieldLabel
app.ChannelIDEditFieldLabel = uilabel(app.LeftPanel);
app.ChannelIDEditFieldLabel.HorizontalAlignment = ‘right’;
app.ChannelIDEditFieldLabel.Position = [12 464 66 22];
app.ChannelIDEditFieldLabel.Text = ‘Channel ID’;
% Create ChannelIDEditField
app.ChannelIDEditField = uieditfield(app.LeftPanel, ‘numeric’);
app.ChannelIDEditField.ValueDisplayFormat = ‘%.0f’;
app.ChannelIDEditField.ValueChangedFcn = createCallbackFcn(app, @ChannelIDEditFieldValueChanged, true);
app.ChannelIDEditField.Position = [93 464 55 22];
app.ChannelIDEditField.Value = 543172;
% Create ReadAPIKeyEditFieldLabel
app.ReadAPIKeyEditFieldLabel = uilabel(app.LeftPanel);
app.ReadAPIKeyEditFieldLabel.HorizontalAlignment = ‘right’;
app.ReadAPIKeyEditFieldLabel.Position = [13 434 74 22];
app.ReadAPIKeyEditFieldLabel.Text = ‘ReadAPIKey’;
% Create ReadAPIKeyEditField
app.ReadAPIKeyEditField = uieditfield(app.LeftPanel, ‘text’);
app.ReadAPIKeyEditField.ValueChangedFcn = createCallbackFcn(app, @ReadAPIKeyEditFieldValueChanged, true);
app.ReadAPIKeyEditField.Position = [102 434 100 22];
app.ReadAPIKeyEditField.Value = ‘0BXYOJW16B7R6DMM’;
% Create F4CheckBox
app.F4CheckBox = uicheckbox(app.LeftPanel);
app.F4CheckBox.ValueChangedFcn = createCallbackFcn(app, @F4CheckBoxValueChanged, true);
app.F4CheckBox.Text = ‘F4’;
app.F4CheckBox.Position = [14 178 36 22];
app.F4CheckBox.Value = true;
% Create RightPanel
app.RightPanel = uipanel(app.GridLayout);
app.RightPanel.Layout.Row = 1;
app.RightPanel.Layout.Column = 2;
% Create StatusLabel
app.StatusLabel = uilabel(app.RightPanel);
app.StatusLabel.Position = [2 1 449 22];
app.StatusLabel.Text = ‘Status’;
% Show the figure after all components are created
app.IoTDataExplorerForThingSpeakUIFigure.Visible = ‘on’;
end
end
% App creation and deletion
methods (Access = public)
% Construct app
function app = IoTDataExplorerForThingSpeakUsingMATLAB
% Create UIFigure and components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.IoTDataExplorerForThingSpeakUIFigure)
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.IoTDataExplorerForThingSpeakUIFigure)
end
end
end
But when we try to run ,we get error:
Unrecognized function or variable ‘updateAppLayout’.
Error in matlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event) (line 62)
newCallback = @(source, event)executeCallback(ams, …
Error using IoTDataExplorerForThingSpeakUsingMATLAB/createComponents (line 324)
Error while evaluating Figure SizeChangedFcn.
Warning: The following error was caught while executing ‘onCleanup’ class destructor:
Brace indexing is not supported for variables of this type.
Error in cell2mat (line 36)
if isnumeric(c{1}) || ischar(c{1}) || islogical(c{1}) || isstruct(c{1})
Error in onCleanup/delete (line 25)
obj.task();
Warning: The following error was caught while executing ‘onCleanup’ class destructor:
Brace indexing is not supported for variables of this type.
Error in cell2mat (line 36)
if isnumeric(c{1}) || ischar(c{1}) || islogical(c{1}) || isstruct(c{1})
Error in onCleanup/delete (line 25)
obj.task();
Error in onCleanup/delete (line 25)
obj.task();
Error inmatlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event)
(line 62)
newCallback = @(source, event)executeCallback(ams, … > In onCleanup/delete (line 25)
In matlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event) (line 62)
In matlab.ui.internal.controller/FigureController/handleClientEvent (line 832)
In matlab.ui.internal.controller/FigureController/handleEvent (line 667)
In matlab.ui.internal.controller.WebCanvasContainerController>@(varargin)this.handleEvent(varargin{:}) (line 45)
Unrecognized function or variable ‘updateAppLayout’.
Error in matlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event) (line 62)
newCallback = @(source, event)executeCallback(ams, …
Error using matlab.ui.internal.controller.FigureController/handleClientEvent (line 832)
Error while evaluating Figure SizeChangedFcn.
>> thingsspeak, iot MATLAB Answers — New Questions
Raspberry Pi support package Install issue after selecting volume
Hi Guys,
This is on OS X 10.11.6
When installing the Raspberry PI support package, after selecting the volume and clicking next I get this error:
"The ‘STRING’ input must be either a char row vector, a cell array of char row vectors, or a string array."
I cannot get any further than this.
Has anyone got any ideas of how to sort this out.
Many thanks
AndyHi Guys,
This is on OS X 10.11.6
When installing the Raspberry PI support package, after selecting the volume and clicking next I get this error:
"The ‘STRING’ input must be either a char row vector, a cell array of char row vectors, or a string array."
I cannot get any further than this.
Has anyone got any ideas of how to sort this out.
Many thanks
Andy Hi Guys,
This is on OS X 10.11.6
When installing the Raspberry PI support package, after selecting the volume and clicking next I get this error:
"The ‘STRING’ input must be either a char row vector, a cell array of char row vectors, or a string array."
I cannot get any further than this.
Has anyone got any ideas of how to sort this out.
Many thanks
Andy raspberry, install MATLAB Answers — New Questions
I have got this message – can’t install MATLAB
Hello,
i tryed to install the software but i got this message:
can someone help me?
thanxHello,
i tryed to install the software but i got this message:
can someone help me?
thanx Hello,
i tryed to install the software but i got this message:
can someone help me?
thanx install MATLAB Answers — New Questions
pop out the vcrt_check just after finish the install
after installing the matlab2010b, it will pop out the VCRT_CHECK.exe. I have no idea what is happening..after installing the matlab2010b, it will pop out the VCRT_CHECK.exe. I have no idea what is happening.. after installing the matlab2010b, it will pop out the VCRT_CHECK.exe. I have no idea what is happening.. install MATLAB Answers — New Questions
How to input pi
How can i enter pi into an equation on matlab?How can i enter pi into an equation on matlab? How can i enter pi into an equation on matlab? pi, cheat sheets MATLAB Answers — New Questions
How to set temp folder for MCR Installer
I am making a Matlab Compile Runtime application on Linux via ‘deploytool’, however when I go to deploy/install my application by running the installer deploytool generates, I am unable to do so as it requires write-access to /tmp (which I don’t have).
I have tried setting a ‘TMP’ environment variable to a workable path for me, which does not seem to change this bevahior (it did change it for running deploytool though).
Any help is appreciated, thanks.I am making a Matlab Compile Runtime application on Linux via ‘deploytool’, however when I go to deploy/install my application by running the installer deploytool generates, I am unable to do so as it requires write-access to /tmp (which I don’t have).
I have tried setting a ‘TMP’ environment variable to a workable path for me, which does not seem to change this bevahior (it did change it for running deploytool though).
Any help is appreciated, thanks. I am making a Matlab Compile Runtime application on Linux via ‘deploytool’, however when I go to deploy/install my application by running the installer deploytool generates, I am unable to do so as it requires write-access to /tmp (which I don’t have).
I have tried setting a ‘TMP’ environment variable to a workable path for me, which does not seem to change this bevahior (it did change it for running deploytool though).
Any help is appreciated, thanks. mcr, install MATLAB Answers — New Questions
In Ap Designer: put new data into a (ui)table
This should be easy… Data comes in from a serial device consisting of a character and a number (time in msec) and I want to insert it into a table on screen.
I’ve got my serial callback working (after much effort) and I thought the next step would be easier. I have created a uitable that is displayed on the screen. Empty at first, called ResultsTable and thus referred to as app.ResultsTable with 2 columns named ‘Event’ and ‘Time’. Everything else about the table is defaulted.
The app.ResultsTable.Data is initially [ ] as expected and as each bit of info comes in I want to add it to the table. Serial callback parsed the input into PType (a character) and PTime (uint32) so why does
app.ResultsTable.Data(app.NextTrial,’Event’) = char(PType);
app.ResultsTable.Data(app.NextTrial,’Time’) = PData;
Give me multiple columns where the number of columns is the ascii value of the character? If PType is ‘A’ I get 64 zeros and then a 65. I’ve tried various combinations of [ PType PData ] ( etc.) { another attempt }. All kinds of complicated merging of multiple tables is described in help but not simply putting new data into a new table within App Designer code (which has to be different than MatLab of course)
And after I get that first row in, I sure hope I can keep adding rows (app.NextTrial is the row index of course) for as long as I have enough memory (maybe 1000 rows?), that I can later export to an excel file or .CSV.
Thanks for the help for an old time C coder new to Matlab.This should be easy… Data comes in from a serial device consisting of a character and a number (time in msec) and I want to insert it into a table on screen.
I’ve got my serial callback working (after much effort) and I thought the next step would be easier. I have created a uitable that is displayed on the screen. Empty at first, called ResultsTable and thus referred to as app.ResultsTable with 2 columns named ‘Event’ and ‘Time’. Everything else about the table is defaulted.
The app.ResultsTable.Data is initially [ ] as expected and as each bit of info comes in I want to add it to the table. Serial callback parsed the input into PType (a character) and PTime (uint32) so why does
app.ResultsTable.Data(app.NextTrial,’Event’) = char(PType);
app.ResultsTable.Data(app.NextTrial,’Time’) = PData;
Give me multiple columns where the number of columns is the ascii value of the character? If PType is ‘A’ I get 64 zeros and then a 65. I’ve tried various combinations of [ PType PData ] ( etc.) { another attempt }. All kinds of complicated merging of multiple tables is described in help but not simply putting new data into a new table within App Designer code (which has to be different than MatLab of course)
And after I get that first row in, I sure hope I can keep adding rows (app.NextTrial is the row index of course) for as long as I have enough memory (maybe 1000 rows?), that I can later export to an excel file or .CSV.
Thanks for the help for an old time C coder new to Matlab. This should be easy… Data comes in from a serial device consisting of a character and a number (time in msec) and I want to insert it into a table on screen.
I’ve got my serial callback working (after much effort) and I thought the next step would be easier. I have created a uitable that is displayed on the screen. Empty at first, called ResultsTable and thus referred to as app.ResultsTable with 2 columns named ‘Event’ and ‘Time’. Everything else about the table is defaulted.
The app.ResultsTable.Data is initially [ ] as expected and as each bit of info comes in I want to add it to the table. Serial callback parsed the input into PType (a character) and PTime (uint32) so why does
app.ResultsTable.Data(app.NextTrial,’Event’) = char(PType);
app.ResultsTable.Data(app.NextTrial,’Time’) = PData;
Give me multiple columns where the number of columns is the ascii value of the character? If PType is ‘A’ I get 64 zeros and then a 65. I’ve tried various combinations of [ PType PData ] ( etc.) { another attempt }. All kinds of complicated merging of multiple tables is described in help but not simply putting new data into a new table within App Designer code (which has to be different than MatLab of course)
And after I get that first row in, I sure hope I can keep adding rows (app.NextTrial is the row index of course) for as long as I have enough memory (maybe 1000 rows?), that I can later export to an excel file or .CSV.
Thanks for the help for an old time C coder new to Matlab. data into table MATLAB Answers — New Questions
How can I hide the black line on the right side of colorbar
Post Content Post Content colorbar, map MATLAB Answers — New Questions
2D or 3D from CST to matlab
i work withh pattern function in matlab but i can get the result and only get err i dont know i can use it or not?
i get text from cst like it for 2D
Theta [deg.] Phi [deg.] Abs(Grlz)[dBi ] Abs(Theta)[dBi ] Phase(Theta)[deg.] Abs(Phi )[dBi ] Phase(Phi )[deg.] Ax.Ratio[dB ]
——————————————————————————————————————————————————
-180.000 90.000 -9.255e+00 -1.298e+01 149.214 -1.165e+01 26.420 5.450e+00
-179.900 90.000 -9.239e+00 -1.295e+01 148.947 -1.165e+01 26.368 5.407e+00
-179.800 90.000 -9.224e+00 -1.292e+01 148.681 -1.164e+01 26.315 5.364e+00
-179.700 90.000 -9.208e+00 -1.289e+01 148.418 -1.163e+01 26.263 5.321e+00
.
.
.
179.600 90.000 -9.319e+00 -1.309e+01 150.304 -1.168e+01 26.638 5.627e+00
179.700 90.000 -9.303e+00 -1.306e+01 150.029 -1.168e+01 26.584 5.582e+00
179.800 90.000 -9.287e+00 -1.303e+01 149.755 -1.167e+01 26.530 5.537e+00
179.900 90.000 -9.271e+00 -1.300e+01 149.484 -1.166e+01 26.477 5.493e+00
in above table i only use first three column which means i like to have pattern in constant phi with various theta
in cst i get this pattern and i want get it in matlab
or about 3d
Theta [deg.] Phi [deg.] Abs(Grlz)[dBi ] Abs(Theta)[dBi ] Phase(Theta)[deg.] Abs(Phi )[dBi ] Phase(Phi )[deg.] Ax.Ratio[dB ]
——————————————————————————————————————————————————
-180.000 -90.000 -9.255e+00 -1.298e+01 329.214 -1.165e+01 206.420 5.450e+00
-175.000 -90.000 -1.014e+01 -1.456e+01 345.709 -1.209e+01 209.583 8.372e+00
-170.000 -90.000 -1.106e+01 -1.607e+01 10.515 -1.271e+01 214.066 1.431e+01
.
.
.
170.000 -85.000 -8.273e+00 -1.118e+01 315.069 -1.139e+01 209.010 2.476e+00
175.000 -85.000 -8.594e+00 -1.155e+01 323.022 -1.166e+01 209.504 3.672e+00
.
.
-180.000 -80.000 -9.255e+00 -1.209e+01 338.042 -1.245e+01 214.316 5.450e+00
-175.000 -80.000 -1.012e+01 -1.327e+01 353.629 -1.299e+01 213.416 8.835e+00
-170.000 -80.000 -1.082e+01 -1.409e+01 16.458 -1.358e+01 212.867 1.684e+01
.
.
160.000 90.000 -1.153e+01 -1.477e+01 248.847 -1.431e+01 48.753 1.504e+01
165.000 90.000 -1.162e+01 -1.622e+01 221.795 -1.347e+01 40.323 3.825e+01
170.000 90.000 -1.106e+01 -1.607e+01 190.515 -1.271e+01 34.066 1.431e+01
175.000 90.000 -1.014e+01 -1.456e+01 165.709 -1.209e+01 29.583 8.372e+00
is it posssible to get them from matlab with patten func or other wayi work withh pattern function in matlab but i can get the result and only get err i dont know i can use it or not?
i get text from cst like it for 2D
Theta [deg.] Phi [deg.] Abs(Grlz)[dBi ] Abs(Theta)[dBi ] Phase(Theta)[deg.] Abs(Phi )[dBi ] Phase(Phi )[deg.] Ax.Ratio[dB ]
——————————————————————————————————————————————————
-180.000 90.000 -9.255e+00 -1.298e+01 149.214 -1.165e+01 26.420 5.450e+00
-179.900 90.000 -9.239e+00 -1.295e+01 148.947 -1.165e+01 26.368 5.407e+00
-179.800 90.000 -9.224e+00 -1.292e+01 148.681 -1.164e+01 26.315 5.364e+00
-179.700 90.000 -9.208e+00 -1.289e+01 148.418 -1.163e+01 26.263 5.321e+00
.
.
.
179.600 90.000 -9.319e+00 -1.309e+01 150.304 -1.168e+01 26.638 5.627e+00
179.700 90.000 -9.303e+00 -1.306e+01 150.029 -1.168e+01 26.584 5.582e+00
179.800 90.000 -9.287e+00 -1.303e+01 149.755 -1.167e+01 26.530 5.537e+00
179.900 90.000 -9.271e+00 -1.300e+01 149.484 -1.166e+01 26.477 5.493e+00
in above table i only use first three column which means i like to have pattern in constant phi with various theta
in cst i get this pattern and i want get it in matlab
or about 3d
Theta [deg.] Phi [deg.] Abs(Grlz)[dBi ] Abs(Theta)[dBi ] Phase(Theta)[deg.] Abs(Phi )[dBi ] Phase(Phi )[deg.] Ax.Ratio[dB ]
——————————————————————————————————————————————————
-180.000 -90.000 -9.255e+00 -1.298e+01 329.214 -1.165e+01 206.420 5.450e+00
-175.000 -90.000 -1.014e+01 -1.456e+01 345.709 -1.209e+01 209.583 8.372e+00
-170.000 -90.000 -1.106e+01 -1.607e+01 10.515 -1.271e+01 214.066 1.431e+01
.
.
.
170.000 -85.000 -8.273e+00 -1.118e+01 315.069 -1.139e+01 209.010 2.476e+00
175.000 -85.000 -8.594e+00 -1.155e+01 323.022 -1.166e+01 209.504 3.672e+00
.
.
-180.000 -80.000 -9.255e+00 -1.209e+01 338.042 -1.245e+01 214.316 5.450e+00
-175.000 -80.000 -1.012e+01 -1.327e+01 353.629 -1.299e+01 213.416 8.835e+00
-170.000 -80.000 -1.082e+01 -1.409e+01 16.458 -1.358e+01 212.867 1.684e+01
.
.
160.000 90.000 -1.153e+01 -1.477e+01 248.847 -1.431e+01 48.753 1.504e+01
165.000 90.000 -1.162e+01 -1.622e+01 221.795 -1.347e+01 40.323 3.825e+01
170.000 90.000 -1.106e+01 -1.607e+01 190.515 -1.271e+01 34.066 1.431e+01
175.000 90.000 -1.014e+01 -1.456e+01 165.709 -1.209e+01 29.583 8.372e+00
is it posssible to get them from matlab with patten func or other way i work withh pattern function in matlab but i can get the result and only get err i dont know i can use it or not?
i get text from cst like it for 2D
Theta [deg.] Phi [deg.] Abs(Grlz)[dBi ] Abs(Theta)[dBi ] Phase(Theta)[deg.] Abs(Phi )[dBi ] Phase(Phi )[deg.] Ax.Ratio[dB ]
——————————————————————————————————————————————————
-180.000 90.000 -9.255e+00 -1.298e+01 149.214 -1.165e+01 26.420 5.450e+00
-179.900 90.000 -9.239e+00 -1.295e+01 148.947 -1.165e+01 26.368 5.407e+00
-179.800 90.000 -9.224e+00 -1.292e+01 148.681 -1.164e+01 26.315 5.364e+00
-179.700 90.000 -9.208e+00 -1.289e+01 148.418 -1.163e+01 26.263 5.321e+00
.
.
.
179.600 90.000 -9.319e+00 -1.309e+01 150.304 -1.168e+01 26.638 5.627e+00
179.700 90.000 -9.303e+00 -1.306e+01 150.029 -1.168e+01 26.584 5.582e+00
179.800 90.000 -9.287e+00 -1.303e+01 149.755 -1.167e+01 26.530 5.537e+00
179.900 90.000 -9.271e+00 -1.300e+01 149.484 -1.166e+01 26.477 5.493e+00
in above table i only use first three column which means i like to have pattern in constant phi with various theta
in cst i get this pattern and i want get it in matlab
or about 3d
Theta [deg.] Phi [deg.] Abs(Grlz)[dBi ] Abs(Theta)[dBi ] Phase(Theta)[deg.] Abs(Phi )[dBi ] Phase(Phi )[deg.] Ax.Ratio[dB ]
——————————————————————————————————————————————————
-180.000 -90.000 -9.255e+00 -1.298e+01 329.214 -1.165e+01 206.420 5.450e+00
-175.000 -90.000 -1.014e+01 -1.456e+01 345.709 -1.209e+01 209.583 8.372e+00
-170.000 -90.000 -1.106e+01 -1.607e+01 10.515 -1.271e+01 214.066 1.431e+01
.
.
.
170.000 -85.000 -8.273e+00 -1.118e+01 315.069 -1.139e+01 209.010 2.476e+00
175.000 -85.000 -8.594e+00 -1.155e+01 323.022 -1.166e+01 209.504 3.672e+00
.
.
-180.000 -80.000 -9.255e+00 -1.209e+01 338.042 -1.245e+01 214.316 5.450e+00
-175.000 -80.000 -1.012e+01 -1.327e+01 353.629 -1.299e+01 213.416 8.835e+00
-170.000 -80.000 -1.082e+01 -1.409e+01 16.458 -1.358e+01 212.867 1.684e+01
.
.
160.000 90.000 -1.153e+01 -1.477e+01 248.847 -1.431e+01 48.753 1.504e+01
165.000 90.000 -1.162e+01 -1.622e+01 221.795 -1.347e+01 40.323 3.825e+01
170.000 90.000 -1.106e+01 -1.607e+01 190.515 -1.271e+01 34.066 1.431e+01
175.000 90.000 -1.014e+01 -1.456e+01 165.709 -1.209e+01 29.583 8.372e+00
is it posssible to get them from matlab with patten func or other way pattern, chart, table, antenna MATLAB Answers — New Questions
How Ansys toolbox works?
How ansys toolbox works for making optimization using genetic algorithmHow ansys toolbox works for making optimization using genetic algorithm How ansys toolbox works for making optimization using genetic algorithm ansys, matlab MATLAB Answers — New Questions
Error while installing MATLAB R2021a
While running setup.exe this message appears "Something Unexpected Occurred
There was an error communicating with the backend services". Please provide a way to solve this issue so that i can intall the product.While running setup.exe this message appears "Something Unexpected Occurred
There was an error communicating with the backend services". Please provide a way to solve this issue so that i can intall the product. While running setup.exe this message appears "Something Unexpected Occurred
There was an error communicating with the backend services". Please provide a way to solve this issue so that i can intall the product. error, install MATLAB Answers — New Questions
Problem in Neural network fitting Matlab R2024a
Hello
I encountered an obstacle in using the Neural Networks window, where after applying NNStart and logging in, I cannot work on the icons at the top of the toolbar, such as training, stopping, training status, etc.
In other words, all icons are inactive.
Please help me resolve this issue.
I am using the trial version with Windows 11
Kind regards.Hello
I encountered an obstacle in using the Neural Networks window, where after applying NNStart and logging in, I cannot work on the icons at the top of the toolbar, such as training, stopping, training status, etc.
In other words, all icons are inactive.
Please help me resolve this issue.
I am using the trial version with Windows 11
Kind regards. Hello
I encountered an obstacle in using the Neural Networks window, where after applying NNStart and logging in, I cannot work on the icons at the top of the toolbar, such as training, stopping, training status, etc.
In other words, all icons are inactive.
Please help me resolve this issue.
I am using the trial version with Windows 11
Kind regards. matlab, nnstart, neural network MATLAB Answers — New Questions