getting the error "Conversion to logical from string is not possible" while using UI table
24 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I use the following functions to make and allow my UI table to be editable.
function UpdateUITable(app, subsystem)
% Return the initial logical values for checkboxes
app.IndvCal = false(size(subsystem.ChannelNames));
%Channels = cellstr(string(subsystem.ChannelNames));
app.Channels = string(subsystem.ChannelNames);
% Create a cell array with channel names and logical values for the checkboxes
UIData = [app.Channels, app.IndvCal];
% Set the CellEditCallback for the UITable
app.UITable.Data = UIData;
end
function UITableCellEdit(app, event)
indices = event.Indices;
newData = event.NewData;
% Update the logical array based on checkbox changes
app.IndvCal(indices(1)) = newData;
% Update the selected channels variables
app.SelectedCal = app.Channels(app.IndvCal);
app.SelectedChannels = app.Channels(indices(1));
% Call the function that uses the selected channels (e.g., data calibration)
updateChannelMeasurementComponents(app)
end
I use these values to determine what data that I have will be calibrated with the following function. I am getting this logical string error and I am unsure why. I want the channels that are selected to be displayed in my graph
function updateLivePlot(app)
% Update the live plot
if isempty(app.DataFIFOBufferch1) || isempty(app.SelectedChannels)
return
end
% Disable interactivity
disableDefaultInteractivity(app.LiveAxes);
% Keep the colors the same after each new data point
app.LiveAxes.ColorOrderIndex = 1;
if isempty(app.LivePlotLine)
% First-Time Setup
app.LivePlotLine = plot(app.LiveAxes, app.TimestampsFIFOBuffer, app.DataFIFOBufferch1(:, app.SelectedChannels));
else
% Update existing plot
for j = 1:numel(app.SelectedChannels)
% Check if the line needs to be extended
if numel(app.LivePlotLine) < j || isempty(app.LivePlotLine(j))
% Use existing axes to plot
app.LivePlotLine(j) = plot(app.LiveAxes, app.TimestampsFIFOBuffer, app.DataFIFOBufferch1(:, app.SelectedChannels(j,1)));
else
% Update existing line
set(app.LivePlotLine(j), 'XData', app.TimestampsFIFOBuffer, 'YData', app.DataFIFOBufferch1(:, app.SelectedChannels(j,1)));
end
end
end
if numel(app.TimestampsFIFOBuffer) > 1
xlim(app.LiveAxes, [app.TimestampsFIFOBuffer(1), app.TimestampsFIFOBuffer(end)]);
end
end
and the graph plots the calibrated and raw data based on the following function. The data feeds into all function continously atm and when channels are selected in the UI table that (in theory) change what is being displayed on the graph. I am wondering If i should add another column to my UI table that can be another logical that would keep track if the channel is off or on and also keep the calibration logical?
function calibratedData = calibrateData(app,data, slopes, intercepts)
% Calibrate the data using slopes and intercepts
calibratedData = data;
for j = 1:numel(app.SelectedChannels)
if app.SelectedChannels(j,1) == true
calibratedData(:,j) = calibratedData(:,j) * slopes(:,j) + intercepts(:,j);
elseif app.SelectedChannels(j,1) == false
calibratedData = app.data;
app.TimewindowEditField.Value = 10;
else
calibratedData = app.data;
end
end
end
Thanks
Réponse acceptée
Walter Roberson
le 11 Mar 2024
app.Channels = string(subsystem.ChannelNames);
app.Channels will store channel names
app.SelectedChannels = app.Channels(indices(1));
app.SelectedChannels will hold one of the channel names.
if app.SelectedChannels(j,1) == true
There you try to compare the channel name to the logical value true
2 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur National Instruments Frame Grabbers dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!