Category: Matlab
Category Archives: Matlab
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
Is there any documentation on how to build a transformer encoder from scratch in matlab?
I am building a transformer encoder, and I came accross the following exchange: https://www.mathworks.com/matlabcentral/fileexchange/107375-transformer-models
However, in the exchange there are examples on how to use a pretrained transformer model. I just need an example on how to build a model. Something to give a general idea so I can build on it. I have studied the basics of transformers but I am having some difficulty building the model from scratch.
Thank you in advance.I am building a transformer encoder, and I came accross the following exchange: https://www.mathworks.com/matlabcentral/fileexchange/107375-transformer-models
However, in the exchange there are examples on how to use a pretrained transformer model. I just need an example on how to build a model. Something to give a general idea so I can build on it. I have studied the basics of transformers but I am having some difficulty building the model from scratch.
Thank you in advance. I am building a transformer encoder, and I came accross the following exchange: https://www.mathworks.com/matlabcentral/fileexchange/107375-transformer-models
However, in the exchange there are examples on how to use a pretrained transformer model. I just need an example on how to build a model. Something to give a general idea so I can build on it. I have studied the basics of transformers but I am having some difficulty building the model from scratch.
Thank you in advance. neural networks, transformers 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
I need help using the corrcoef function to calculate PRx (pressure reactivity index)
Hi everyone! I need to calculate PRx (pressure reactivity index) using ICP (intracranial pressure) and mean ABP (mean arterial blood pressure) data. PRx is known as "pressure reactivity index is calculated as the degree of statistical correlation between the slow wave components of mean arterial pressure (ABP) and intracranial pressure (ICP)". I need to do this in order to calculate a different hypothetical reactivity index. I have PRx data- so my idea was to use the given PRx data and compare it to the calculated PRx data to ensure it is correct.
This is the script to display the PRx data that was given to me:
%PRx_display
% Load PRx data from MAT file
load(‘PRx,data_part1of1’);
PRx_values = measurement_data;
disp(‘PRx Values:’);
disp(PRx_values);
% Plot PRx values
figure;
plot(PRx_values);
xlabel(‘Time’);
ylabel(‘PRx Value’);
title(‘PRx’);
grid on;
% Calculate average PRx
average_PRx = mean(PRx_values);
% Display average PRx
fprintf(‘Average PRx: %.4f\n’, average_PRx);
This is the script I am trying to calculate PRx with:
%PRx_calc
% Load ICP and MAP data
load("ICP,data_part1of1");
ICP_time_vector = round(time_vector); % Assuming time_vector in ICP file
ICP_data = measurement_data;
load("ABP,mean,data_part1of1");
ABP_time_vector = round(time_vector); % Assuming time_vector in ABP file
ABP_data = measurement_data;
% Remove duplicate time points from ICP
[ICP_time_vector, uniqueIdx] = unique(ICP_time_vector);
ICP_data = ICP_data(uniqueIdx);
% Remove duplicate time points from ABP
[ABP_time_vector, uniqueIdx] = unique(ABP_time_vector);
ABP_data = ABP_data(uniqueIdx);
% Ensure consistent dimensions
if length(ICP_time_vector) ~= length(ICP_data)
error(‘ICP_time_vector and ICP_data have different lengths’);
end
if length(ABP_time_vector) ~= length(ABP_data)
error(‘ABP_time_vector and ABP_data have different lengths’);
end
% Interpolating ABP to match ICP time vector
if ~isequal(ICP_time_vector, ABP_time_vector)
ABP_data = interp1(ABP_time_vector, ABP_data, ICP_time_vector, ‘linear’, ‘extrap’);
end
% Combine ICP data and aligned ABP data
ICP = [ICP_time_vector(:), ICP_data(:)]; % Ensure column vectors
ABP = [ICP_time_vector(:), ABP_data(:)]; % ABP_data is now interpolated to match ICP_time_vector
% Parameters
windowSize = 30 * 10; % 30 windows of 10 seconds
stepSize = 60; % Update every 60 seconds
n = length(ICP_time_vector); % Number of data points
% Preallocate PRx array
PRx = NaN(floor((n – windowSize) / stepSize) + 1, 1);
% Compute moving correlation coefficient
for i = 1:stepSize:(n – windowSize + 1)
% Extract current window of data
windowICP = ICP(i:i + windowSize – 1, 2);
windowABP = ABP(i:i + windowSize – 1, 2);
% Calculate correlation coefficient for the current window
R = corrcoef(windowICP, windowABP);
% Store PRx (correlation coefficient of ICP and ABP)
PRx(floor(i / stepSize) + 1) = R(1, 2);
end
% Calculate average PRx ignoring NaN values
averagePRx = sum(PRx, ‘omitnan’) / sum(~isnan(PRx));
% Display average PRx in the command window
fprintf(‘Average PRx: %.4f\n’, averagePRx);
% Plot PRx vs Time in minutes
figure;
plot((0:length(PRx)-1)*stepSize/60, PRx); % Convert to minutes
title(‘PRx vs Time’);
xlabel(‘Time (minutes)’);
ylabel(‘PRx Values’);
I thought the calculation script would work, but it doesn’t. For instance, for a certain set of data, PRx_calc.m gives me an average PRx value of 0.32, while PRx_display.m gives me 0.52. The trend of the plots look the same, but the PRx_calc.m’s for some reason looks shifted down and distorted a little bit. I am looking for help with the way I am using the corrcoef function and general debugging help.
Here are the first 20 values of each type of data: First 20 values of
ICP: 10 10 10 10 11 11 11 11 10 11 10 11 11 11 11 11 10 11 11 11
First 20 values of
ABP: 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
First 20 calculated
PRx values: NaN NaN NaN NaN NaN NaN -0.0838 -0.2111 -0.0586 0.1704 0.4276 0.3193 0.3417 0.4128 0.5488 0.4790 0.5207 0.6822 0.7107 0.5235
Average PRx: 0.3209
The PRx_calc script, which produces the above values, should produce the given PRx values(below).
First 20 PRx Values: 0.6150 0.5996 0.6010 0.6276 0.7499 0.4495 0.4488 0.4492 0.5078 0.7263 0.7290 0.7343 0.7490 0.7561 0.6997 0.4609 0.2567 0.5935 0.7317 0.6666
Average PRx: 0.5247
Please let me know if there is anything else I should add, more data points, graphs, etc. Thank you!Hi everyone! I need to calculate PRx (pressure reactivity index) using ICP (intracranial pressure) and mean ABP (mean arterial blood pressure) data. PRx is known as "pressure reactivity index is calculated as the degree of statistical correlation between the slow wave components of mean arterial pressure (ABP) and intracranial pressure (ICP)". I need to do this in order to calculate a different hypothetical reactivity index. I have PRx data- so my idea was to use the given PRx data and compare it to the calculated PRx data to ensure it is correct.
This is the script to display the PRx data that was given to me:
%PRx_display
% Load PRx data from MAT file
load(‘PRx,data_part1of1’);
PRx_values = measurement_data;
disp(‘PRx Values:’);
disp(PRx_values);
% Plot PRx values
figure;
plot(PRx_values);
xlabel(‘Time’);
ylabel(‘PRx Value’);
title(‘PRx’);
grid on;
% Calculate average PRx
average_PRx = mean(PRx_values);
% Display average PRx
fprintf(‘Average PRx: %.4f\n’, average_PRx);
This is the script I am trying to calculate PRx with:
%PRx_calc
% Load ICP and MAP data
load("ICP,data_part1of1");
ICP_time_vector = round(time_vector); % Assuming time_vector in ICP file
ICP_data = measurement_data;
load("ABP,mean,data_part1of1");
ABP_time_vector = round(time_vector); % Assuming time_vector in ABP file
ABP_data = measurement_data;
% Remove duplicate time points from ICP
[ICP_time_vector, uniqueIdx] = unique(ICP_time_vector);
ICP_data = ICP_data(uniqueIdx);
% Remove duplicate time points from ABP
[ABP_time_vector, uniqueIdx] = unique(ABP_time_vector);
ABP_data = ABP_data(uniqueIdx);
% Ensure consistent dimensions
if length(ICP_time_vector) ~= length(ICP_data)
error(‘ICP_time_vector and ICP_data have different lengths’);
end
if length(ABP_time_vector) ~= length(ABP_data)
error(‘ABP_time_vector and ABP_data have different lengths’);
end
% Interpolating ABP to match ICP time vector
if ~isequal(ICP_time_vector, ABP_time_vector)
ABP_data = interp1(ABP_time_vector, ABP_data, ICP_time_vector, ‘linear’, ‘extrap’);
end
% Combine ICP data and aligned ABP data
ICP = [ICP_time_vector(:), ICP_data(:)]; % Ensure column vectors
ABP = [ICP_time_vector(:), ABP_data(:)]; % ABP_data is now interpolated to match ICP_time_vector
% Parameters
windowSize = 30 * 10; % 30 windows of 10 seconds
stepSize = 60; % Update every 60 seconds
n = length(ICP_time_vector); % Number of data points
% Preallocate PRx array
PRx = NaN(floor((n – windowSize) / stepSize) + 1, 1);
% Compute moving correlation coefficient
for i = 1:stepSize:(n – windowSize + 1)
% Extract current window of data
windowICP = ICP(i:i + windowSize – 1, 2);
windowABP = ABP(i:i + windowSize – 1, 2);
% Calculate correlation coefficient for the current window
R = corrcoef(windowICP, windowABP);
% Store PRx (correlation coefficient of ICP and ABP)
PRx(floor(i / stepSize) + 1) = R(1, 2);
end
% Calculate average PRx ignoring NaN values
averagePRx = sum(PRx, ‘omitnan’) / sum(~isnan(PRx));
% Display average PRx in the command window
fprintf(‘Average PRx: %.4f\n’, averagePRx);
% Plot PRx vs Time in minutes
figure;
plot((0:length(PRx)-1)*stepSize/60, PRx); % Convert to minutes
title(‘PRx vs Time’);
xlabel(‘Time (minutes)’);
ylabel(‘PRx Values’);
I thought the calculation script would work, but it doesn’t. For instance, for a certain set of data, PRx_calc.m gives me an average PRx value of 0.32, while PRx_display.m gives me 0.52. The trend of the plots look the same, but the PRx_calc.m’s for some reason looks shifted down and distorted a little bit. I am looking for help with the way I am using the corrcoef function and general debugging help.
Here are the first 20 values of each type of data: First 20 values of
ICP: 10 10 10 10 11 11 11 11 10 11 10 11 11 11 11 11 10 11 11 11
First 20 values of
ABP: 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
First 20 calculated
PRx values: NaN NaN NaN NaN NaN NaN -0.0838 -0.2111 -0.0586 0.1704 0.4276 0.3193 0.3417 0.4128 0.5488 0.4790 0.5207 0.6822 0.7107 0.5235
Average PRx: 0.3209
The PRx_calc script, which produces the above values, should produce the given PRx values(below).
First 20 PRx Values: 0.6150 0.5996 0.6010 0.6276 0.7499 0.4495 0.4488 0.4492 0.5078 0.7263 0.7290 0.7343 0.7490 0.7561 0.6997 0.4609 0.2567 0.5935 0.7317 0.6666
Average PRx: 0.5247
Please let me know if there is anything else I should add, more data points, graphs, etc. Thank you! Hi everyone! I need to calculate PRx (pressure reactivity index) using ICP (intracranial pressure) and mean ABP (mean arterial blood pressure) data. PRx is known as "pressure reactivity index is calculated as the degree of statistical correlation between the slow wave components of mean arterial pressure (ABP) and intracranial pressure (ICP)". I need to do this in order to calculate a different hypothetical reactivity index. I have PRx data- so my idea was to use the given PRx data and compare it to the calculated PRx data to ensure it is correct.
This is the script to display the PRx data that was given to me:
%PRx_display
% Load PRx data from MAT file
load(‘PRx,data_part1of1’);
PRx_values = measurement_data;
disp(‘PRx Values:’);
disp(PRx_values);
% Plot PRx values
figure;
plot(PRx_values);
xlabel(‘Time’);
ylabel(‘PRx Value’);
title(‘PRx’);
grid on;
% Calculate average PRx
average_PRx = mean(PRx_values);
% Display average PRx
fprintf(‘Average PRx: %.4f\n’, average_PRx);
This is the script I am trying to calculate PRx with:
%PRx_calc
% Load ICP and MAP data
load("ICP,data_part1of1");
ICP_time_vector = round(time_vector); % Assuming time_vector in ICP file
ICP_data = measurement_data;
load("ABP,mean,data_part1of1");
ABP_time_vector = round(time_vector); % Assuming time_vector in ABP file
ABP_data = measurement_data;
% Remove duplicate time points from ICP
[ICP_time_vector, uniqueIdx] = unique(ICP_time_vector);
ICP_data = ICP_data(uniqueIdx);
% Remove duplicate time points from ABP
[ABP_time_vector, uniqueIdx] = unique(ABP_time_vector);
ABP_data = ABP_data(uniqueIdx);
% Ensure consistent dimensions
if length(ICP_time_vector) ~= length(ICP_data)
error(‘ICP_time_vector and ICP_data have different lengths’);
end
if length(ABP_time_vector) ~= length(ABP_data)
error(‘ABP_time_vector and ABP_data have different lengths’);
end
% Interpolating ABP to match ICP time vector
if ~isequal(ICP_time_vector, ABP_time_vector)
ABP_data = interp1(ABP_time_vector, ABP_data, ICP_time_vector, ‘linear’, ‘extrap’);
end
% Combine ICP data and aligned ABP data
ICP = [ICP_time_vector(:), ICP_data(:)]; % Ensure column vectors
ABP = [ICP_time_vector(:), ABP_data(:)]; % ABP_data is now interpolated to match ICP_time_vector
% Parameters
windowSize = 30 * 10; % 30 windows of 10 seconds
stepSize = 60; % Update every 60 seconds
n = length(ICP_time_vector); % Number of data points
% Preallocate PRx array
PRx = NaN(floor((n – windowSize) / stepSize) + 1, 1);
% Compute moving correlation coefficient
for i = 1:stepSize:(n – windowSize + 1)
% Extract current window of data
windowICP = ICP(i:i + windowSize – 1, 2);
windowABP = ABP(i:i + windowSize – 1, 2);
% Calculate correlation coefficient for the current window
R = corrcoef(windowICP, windowABP);
% Store PRx (correlation coefficient of ICP and ABP)
PRx(floor(i / stepSize) + 1) = R(1, 2);
end
% Calculate average PRx ignoring NaN values
averagePRx = sum(PRx, ‘omitnan’) / sum(~isnan(PRx));
% Display average PRx in the command window
fprintf(‘Average PRx: %.4f\n’, averagePRx);
% Plot PRx vs Time in minutes
figure;
plot((0:length(PRx)-1)*stepSize/60, PRx); % Convert to minutes
title(‘PRx vs Time’);
xlabel(‘Time (minutes)’);
ylabel(‘PRx Values’);
I thought the calculation script would work, but it doesn’t. For instance, for a certain set of data, PRx_calc.m gives me an average PRx value of 0.32, while PRx_display.m gives me 0.52. The trend of the plots look the same, but the PRx_calc.m’s for some reason looks shifted down and distorted a little bit. I am looking for help with the way I am using the corrcoef function and general debugging help.
Here are the first 20 values of each type of data: First 20 values of
ICP: 10 10 10 10 11 11 11 11 10 11 10 11 11 11 11 11 10 11 11 11
First 20 values of
ABP: 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89 89
First 20 calculated
PRx values: NaN NaN NaN NaN NaN NaN -0.0838 -0.2111 -0.0586 0.1704 0.4276 0.3193 0.3417 0.4128 0.5488 0.4790 0.5207 0.6822 0.7107 0.5235
Average PRx: 0.3209
The PRx_calc script, which produces the above values, should produce the given PRx values(below).
First 20 PRx Values: 0.6150 0.5996 0.6010 0.6276 0.7499 0.4495 0.4488 0.4492 0.5078 0.7263 0.7290 0.7343 0.7490 0.7561 0.6997 0.4609 0.2567 0.5935 0.7317 0.6666
Average PRx: 0.5247
Please let me know if there is anything else I should add, more data points, graphs, etc. Thank you! corrcoef MATLAB Answers — New Questions
Can I deploy a multiwindow app as a web app using MATLAB Web App Server?
This documentation page shows the workflow of creating a multiwindow app with the App Designer.
https://www.mathworks.com/help/matlab/creating_guis/creating-multiwindow-apps-in-app-designer.html
However, after successfully deploying and launching the app from the web app server, I get errors such as:
Web Apps does not support multiwindow apps
Or:
Error using errordlg (line 2)
Web Apps does not support errordlg.
Can I deploy a multiwindow app as a web app using MATLAB Web App Server?This documentation page shows the workflow of creating a multiwindow app with the App Designer.
https://www.mathworks.com/help/matlab/creating_guis/creating-multiwindow-apps-in-app-designer.html
However, after successfully deploying and launching the app from the web app server, I get errors such as:
Web Apps does not support multiwindow apps
Or:
Error using errordlg (line 2)
Web Apps does not support errordlg.
Can I deploy a multiwindow app as a web app using MATLAB Web App Server? This documentation page shows the workflow of creating a multiwindow app with the App Designer.
https://www.mathworks.com/help/matlab/creating_guis/creating-multiwindow-apps-in-app-designer.html
However, after successfully deploying and launching the app from the web app server, I get errors such as:
Web Apps does not support multiwindow apps
Or:
Error using errordlg (line 2)
Web Apps does not support errordlg.
Can I deploy a multiwindow app as a web app using MATLAB Web App Server? multiwindowapp, webapplimitations MATLAB Answers — New Questions
Get singular sagittal slice from nifti file saved as axial slices
Hello, with the following code i’m able to retrieve a single axial slice from this nifti file of a lung CT scan. I would like to know how to be able to save a slice from another view, such as sagittal or coronal in a separate image format such at png or jpg for image processing.
L1 = load_nii(‘lung_029.nii’);
NumSlices = size(L1.img,3)
S = L1.img(:,:,125);
figure
imshow(S)
I’m using the image processing toolbox and tools for nifti and analyze image add ons.Hello, with the following code i’m able to retrieve a single axial slice from this nifti file of a lung CT scan. I would like to know how to be able to save a slice from another view, such as sagittal or coronal in a separate image format such at png or jpg for image processing.
L1 = load_nii(‘lung_029.nii’);
NumSlices = size(L1.img,3)
S = L1.img(:,:,125);
figure
imshow(S)
I’m using the image processing toolbox and tools for nifti and analyze image add ons. Hello, with the following code i’m able to retrieve a single axial slice from this nifti file of a lung CT scan. I would like to know how to be able to save a slice from another view, such as sagittal or coronal in a separate image format such at png or jpg for image processing.
L1 = load_nii(‘lung_029.nii’);
NumSlices = size(L1.img,3)
S = L1.img(:,:,125);
figure
imshow(S)
I’m using the image processing toolbox and tools for nifti and analyze image add ons. nifti, image processing, medical images MATLAB Answers — New Questions
Code not displaying figure
I was told to implement this code form a texbok, but it isn’t displaying figure like in textbook. Last lines separated by enter has display figure part
I prefer to keep it together as one code. I am very new to matlab.
close all
%image parameters
W = 400;
H = 400;
% object parameters
rho = 200;
A = 0.4;
B = 0.2;
alpha = pi /10;
xo = 0.3;
yo = 0.5;
% backprojection parameters
ntheta = 100;
srange = 2;
ns = 100;
function [P] = ellipseproj(A, B, rho, theta, s, alpha, xo, yo)
gamma = atan2(yo, xo);
d = sqrt( xo * xo + yo * yo);
thetanew = theta – alpha;
snew = s – d * cos(gamma – theta);
% use translated/rotated values
s = snew;
theta = thetanew;
% find a^2 (theta)
ct = cos(theta);
st = sin(theta);
a2 = A*A*ct*ct + B*B*st*st;
atheta = sqrt(a2);
% return value if outside ellipse
P = 0;
if( abs(s) <= atheta )
% inside ellipse
P = 2 * rho * A * B / a2 * sqrt(a2 – s * s);
end
end %added
function [projmat, svals, thetavals] = …
ellipseprojmat(A, B, ntheta, ns, srange, rho, alpha, xo, yo)
thetamin = 0;
thetamax = pi;
% each row is a projection at a certain angle
projmat = zeros(ntheta, ns);
smin = -srange;
smax = srange;
dtheta = pi/(ntheta – 1);
ds = (smax – smin)/(ns – 1);
svals = smin:ds:smax;
thetavals = thetamin:dtheta:thetamax;
pn = 1;
for theta = thetavals
% calculate all points on the projection line
P = zeros(ns, 1);
ip = 1;
for s = svals
% simple ellipse
[p] = ellipseproj(A, B, rho, theta, s, alpha, xo, yo);
P(ip) = p;
ip = ip + 1;
end
% save projection as one row of matrix
projmat(pn, 🙂 = P’;
pn = pn + 1;
end
end %added
function [b] = bpsolve(W, H, projmat, svals, thetavals)
ntheta = length(thetavals);
ns = length(svals);
srange = svals(ns);
b = zeros(H, W);
for iy = 1:H
for ix = 1:W
x = 2 * (ix – 1)/(W – 1) – 1;
y = 1 – 2 * (iy – 1)/(H – 1);
% projmat is the P values, each row is P(s) for a given theta
bsum = 0;
for itheta = 1:ntheta
theta = thetavals(itheta);
s =x*cos(theta) + y*sin(theta);
is = (s + srange)/(srange*2)*(ns – 1) + 1;
is = round(is);
if(is < 1)
is = 1;
end
if(is > ns)
is = ns;
end
Ptheta = projmat(itheta, is);
bsum = bsum + Ptheta;
end
b(iy, ix) = bsum;
end
end
% image parameters
W = 400;
H = 400;
% object parameters
% rho = 200;
A = 0.4;
B = 0.2;
alpha = pi/10;
xo = 0.3;
yo = 0.5;
% backprojection parameters
ntheta = 100;
srange = 2;
ns = 100;
% generate projections
[projmat, svals, thetavals] = …
ellipseprojmat(A, B, ntheta, ns, srange, rho, alpha, xo, yo); % solve using backprojection
[b] = bpsolve(W, H, projmat, svals, thetavals);
% scale for image display
b = b/max(max(b)); b = b*255;
bi = uint8(b);
figure(1);
clf
image(bi);
colormap(gray(256));
box(‘on’);
axis(‘off’);
shg;
saveas(gcf,’CompileData.png’);
end %addedI was told to implement this code form a texbok, but it isn’t displaying figure like in textbook. Last lines separated by enter has display figure part
I prefer to keep it together as one code. I am very new to matlab.
close all
%image parameters
W = 400;
H = 400;
% object parameters
rho = 200;
A = 0.4;
B = 0.2;
alpha = pi /10;
xo = 0.3;
yo = 0.5;
% backprojection parameters
ntheta = 100;
srange = 2;
ns = 100;
function [P] = ellipseproj(A, B, rho, theta, s, alpha, xo, yo)
gamma = atan2(yo, xo);
d = sqrt( xo * xo + yo * yo);
thetanew = theta – alpha;
snew = s – d * cos(gamma – theta);
% use translated/rotated values
s = snew;
theta = thetanew;
% find a^2 (theta)
ct = cos(theta);
st = sin(theta);
a2 = A*A*ct*ct + B*B*st*st;
atheta = sqrt(a2);
% return value if outside ellipse
P = 0;
if( abs(s) <= atheta )
% inside ellipse
P = 2 * rho * A * B / a2 * sqrt(a2 – s * s);
end
end %added
function [projmat, svals, thetavals] = …
ellipseprojmat(A, B, ntheta, ns, srange, rho, alpha, xo, yo)
thetamin = 0;
thetamax = pi;
% each row is a projection at a certain angle
projmat = zeros(ntheta, ns);
smin = -srange;
smax = srange;
dtheta = pi/(ntheta – 1);
ds = (smax – smin)/(ns – 1);
svals = smin:ds:smax;
thetavals = thetamin:dtheta:thetamax;
pn = 1;
for theta = thetavals
% calculate all points on the projection line
P = zeros(ns, 1);
ip = 1;
for s = svals
% simple ellipse
[p] = ellipseproj(A, B, rho, theta, s, alpha, xo, yo);
P(ip) = p;
ip = ip + 1;
end
% save projection as one row of matrix
projmat(pn, 🙂 = P’;
pn = pn + 1;
end
end %added
function [b] = bpsolve(W, H, projmat, svals, thetavals)
ntheta = length(thetavals);
ns = length(svals);
srange = svals(ns);
b = zeros(H, W);
for iy = 1:H
for ix = 1:W
x = 2 * (ix – 1)/(W – 1) – 1;
y = 1 – 2 * (iy – 1)/(H – 1);
% projmat is the P values, each row is P(s) for a given theta
bsum = 0;
for itheta = 1:ntheta
theta = thetavals(itheta);
s =x*cos(theta) + y*sin(theta);
is = (s + srange)/(srange*2)*(ns – 1) + 1;
is = round(is);
if(is < 1)
is = 1;
end
if(is > ns)
is = ns;
end
Ptheta = projmat(itheta, is);
bsum = bsum + Ptheta;
end
b(iy, ix) = bsum;
end
end
% image parameters
W = 400;
H = 400;
% object parameters
% rho = 200;
A = 0.4;
B = 0.2;
alpha = pi/10;
xo = 0.3;
yo = 0.5;
% backprojection parameters
ntheta = 100;
srange = 2;
ns = 100;
% generate projections
[projmat, svals, thetavals] = …
ellipseprojmat(A, B, ntheta, ns, srange, rho, alpha, xo, yo); % solve using backprojection
[b] = bpsolve(W, H, projmat, svals, thetavals);
% scale for image display
b = b/max(max(b)); b = b*255;
bi = uint8(b);
figure(1);
clf
image(bi);
colormap(gray(256));
box(‘on’);
axis(‘off’);
shg;
saveas(gcf,’CompileData.png’);
end %added I was told to implement this code form a texbok, but it isn’t displaying figure like in textbook. Last lines separated by enter has display figure part
I prefer to keep it together as one code. I am very new to matlab.
close all
%image parameters
W = 400;
H = 400;
% object parameters
rho = 200;
A = 0.4;
B = 0.2;
alpha = pi /10;
xo = 0.3;
yo = 0.5;
% backprojection parameters
ntheta = 100;
srange = 2;
ns = 100;
function [P] = ellipseproj(A, B, rho, theta, s, alpha, xo, yo)
gamma = atan2(yo, xo);
d = sqrt( xo * xo + yo * yo);
thetanew = theta – alpha;
snew = s – d * cos(gamma – theta);
% use translated/rotated values
s = snew;
theta = thetanew;
% find a^2 (theta)
ct = cos(theta);
st = sin(theta);
a2 = A*A*ct*ct + B*B*st*st;
atheta = sqrt(a2);
% return value if outside ellipse
P = 0;
if( abs(s) <= atheta )
% inside ellipse
P = 2 * rho * A * B / a2 * sqrt(a2 – s * s);
end
end %added
function [projmat, svals, thetavals] = …
ellipseprojmat(A, B, ntheta, ns, srange, rho, alpha, xo, yo)
thetamin = 0;
thetamax = pi;
% each row is a projection at a certain angle
projmat = zeros(ntheta, ns);
smin = -srange;
smax = srange;
dtheta = pi/(ntheta – 1);
ds = (smax – smin)/(ns – 1);
svals = smin:ds:smax;
thetavals = thetamin:dtheta:thetamax;
pn = 1;
for theta = thetavals
% calculate all points on the projection line
P = zeros(ns, 1);
ip = 1;
for s = svals
% simple ellipse
[p] = ellipseproj(A, B, rho, theta, s, alpha, xo, yo);
P(ip) = p;
ip = ip + 1;
end
% save projection as one row of matrix
projmat(pn, 🙂 = P’;
pn = pn + 1;
end
end %added
function [b] = bpsolve(W, H, projmat, svals, thetavals)
ntheta = length(thetavals);
ns = length(svals);
srange = svals(ns);
b = zeros(H, W);
for iy = 1:H
for ix = 1:W
x = 2 * (ix – 1)/(W – 1) – 1;
y = 1 – 2 * (iy – 1)/(H – 1);
% projmat is the P values, each row is P(s) for a given theta
bsum = 0;
for itheta = 1:ntheta
theta = thetavals(itheta);
s =x*cos(theta) + y*sin(theta);
is = (s + srange)/(srange*2)*(ns – 1) + 1;
is = round(is);
if(is < 1)
is = 1;
end
if(is > ns)
is = ns;
end
Ptheta = projmat(itheta, is);
bsum = bsum + Ptheta;
end
b(iy, ix) = bsum;
end
end
% image parameters
W = 400;
H = 400;
% object parameters
% rho = 200;
A = 0.4;
B = 0.2;
alpha = pi/10;
xo = 0.3;
yo = 0.5;
% backprojection parameters
ntheta = 100;
srange = 2;
ns = 100;
% generate projections
[projmat, svals, thetavals] = …
ellipseprojmat(A, B, ntheta, ns, srange, rho, alpha, xo, yo); % solve using backprojection
[b] = bpsolve(W, H, projmat, svals, thetavals);
% scale for image display
b = b/max(max(b)); b = b*255;
bi = uint8(b);
figure(1);
clf
image(bi);
colormap(gray(256));
box(‘on’);
axis(‘off’);
shg;
saveas(gcf,’CompileData.png’);
end %added figure MATLAB Answers — New Questions
Extract the information of inside and outside of a contourf
Hello everyone,
I have a single line of code, quite simple, thanks to which I get (visually) exactly what I need:
h=figure; [pippo1, pippo2]=contourf(AZ,EL,FF, [0, 0]);
where the input arguments have size 301×301. The plot I get is like this:
As you can see, the outside of the contour is not only the big cyan area, but also some small areas in the white (not filled) polygon. I need the coordinates of the outside polygon (the whole cyan region) but I couldn’t extract them from either "h" or "pippo2". Please note, I DON’T NEED the coordinates of the single contours, because if I extract XDATA and YDATA they lose the information about "the inside" and the "outside". I need to extract, in some way, a single contour that represents the whole cyan area, and another one that represents the complementary (white) one.
Thanks a lot!Hello everyone,
I have a single line of code, quite simple, thanks to which I get (visually) exactly what I need:
h=figure; [pippo1, pippo2]=contourf(AZ,EL,FF, [0, 0]);
where the input arguments have size 301×301. The plot I get is like this:
As you can see, the outside of the contour is not only the big cyan area, but also some small areas in the white (not filled) polygon. I need the coordinates of the outside polygon (the whole cyan region) but I couldn’t extract them from either "h" or "pippo2". Please note, I DON’T NEED the coordinates of the single contours, because if I extract XDATA and YDATA they lose the information about "the inside" and the "outside". I need to extract, in some way, a single contour that represents the whole cyan area, and another one that represents the complementary (white) one.
Thanks a lot! Hello everyone,
I have a single line of code, quite simple, thanks to which I get (visually) exactly what I need:
h=figure; [pippo1, pippo2]=contourf(AZ,EL,FF, [0, 0]);
where the input arguments have size 301×301. The plot I get is like this:
As you can see, the outside of the contour is not only the big cyan area, but also some small areas in the white (not filled) polygon. I need the coordinates of the outside polygon (the whole cyan region) but I couldn’t extract them from either "h" or "pippo2". Please note, I DON’T NEED the coordinates of the single contours, because if I extract XDATA and YDATA they lose the information about "the inside" and the "outside". I need to extract, in some way, a single contour that represents the whole cyan area, and another one that represents the complementary (white) one.
Thanks a lot! outside and inside of contourf MATLAB Answers — New Questions
Code Generation from script file
I need information about tool box where I can generate code for SOC Estimations using MATLAB ODE solvers in (.m) Script file.I need information about tool box where I can generate code for SOC Estimations using MATLAB ODE solvers in (.m) Script file. I need information about tool box where I can generate code for SOC Estimations using MATLAB ODE solvers in (.m) Script file. bms MATLAB Answers — New Questions