Clear Filters
Clear Filters

Initializing UI Table App Designer

6 views (last 30 days)
Richard
Richard on 26 Jun 2023
Answered: Divyajyoti Nayak on 12 Jul 2023
Hello,
I am trying to get a UI Table to show seven columns of Data a check box, a number, two names, and three checkboxes. I continue to get an error which is shwon below despite the fact that when I use run they all appear to be column vector which have six items a piece.This error shows up after pressing a button which is supposed to populate the data into the table which is wanted the code for the callback is shown below. Error using horzcat
Dimensions of arrays being concatenated are not consistent. Consider converting input arrays to the same type before concatenating.
Error in StandardProcessing/AppearButtonPushed (line 89)
app.Total = [includee, number, cellstr(app.fileNames), cellstr(app.names), app.external, app.zero, app.invert];
I have included the code down below which is producing this error. I also have already set the table columnformat in the start up function for the app. I have ran the size function on each of the arrays and they all return 6 1 for the inputted data. Any help with this error would be much appreciated.
l = length(n);%n is the names array
app.names = strings([l,1]);
app.fileNames = strings([l,1]); %Initializing arrays to hold data later
number = zeros([l,1]);
counter = 0;
for i = 1:l %Finding channels which are not events
if contains(n(i),"EVENT") == 0 %Getting only the data which I do want displayed
counter = counter +1; %Saving the information
number(counter) = counter;
app.names(counter) = n(i);
temp = strcat("Ch",int2str(app.Front.DATData(i).Ch));
app.fileNames(counter) = strcat(temp,".dat");
end
end
%Initializing arrays for table
includee = true([counter,1]); %initializing logical arrays here
app.external = false([counter,1]);
app.invert = false([counter,1]);
app.zero = false([counter,1]);
number(1+counter:l) = [];
app.names((1+counter):l) = []; %Getting rid of empty parts of the array
app.fileNames((counter+1):l) = [];
app.Total = [includee, number, cellstr(app.fileNames), cellstr(app.names), app.external, app.zero, app.invert]; %Putting all of the columns together

Answers (1)

Divyajyoti Nayak
Divyajyoti Nayak on 12 Jul 2023
Hi Richard,
This error is caused because you are converting the string arrays into cell arrays, because of which while concatenation the logical arrays get converted into 1X1 cell arrays. This gives the incinsistent sizes error.
To avoid this just don't convert the string arrays into cell arrays or convert the logical arrays into same size cell arrays.

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!