How to put matrix into a table (App designer)

25 vues (au cours des 30 derniers jours)
Mena Abdaullah
Mena Abdaullah le 11 Mai 2021
Hello. I have a program that produces velocity vs time. The loop calculates the values of Vx and Vz. I tried to make this data into a table like shown in the picture but it didn't work. I only manged to put the time column but when i try to write: app.UITable.Data = [B vx(i)]. It says dimensions of arrays being concatenated are not consistant.
thanks

Réponses (1)

Arthi Sathyamurthi
Arthi Sathyamurthi le 29 Juil 2021
Hello Mena,
The error “dimensions of arrays being concatenated are not consistent” is encountered when you try to concatenate arrays that do not have compatible sizes. From the image shared, I assume the variable ‘B’ is of size 10*1 and the variable ‘vx’ is of size 1*10. And, when you concatenate as [B vx(i)] the size of the the variable vx(i) is 1*1. Hence a size mismatch happens.
To solve this issue, after the ‘for’ loop you can create a multicolumn table and add the table values in the UI table. This can be done using the snippet below
fig = uifigure;
tdata = table(B',vx,'VariableNames',{'Time','VX'});
uit = uitable(fig,'Data',tdata);
Or else after the ‘for’ loop you can concatenate arrays as [B’ vx] or [t vx] and assign it to the ‘Data’ of UITable. This can be done using the snippet below
app.UITable.Data = [B' vx];
You can look at the following MathWorks documentation link to know how to design a table in App Designer

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by