How to put matrix into a table (App designer)

20 ビュー (過去 30 日間)
Mena Abdaullah
Mena Abdaullah 2021 年 5 月 11 日
回答済み: Arthi Sathyamurthi 2021 年 7 月 29 日
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

回答 (1 件)

Arthi Sathyamurthi
Arthi Sathyamurthi 2021 年 7 月 29 日
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

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by