フィルターのクリア

Creating multidimensional table from multidimensional array

17 ビュー (過去 30 日間)
Ali Tawfik
Ali Tawfik 2020 年 5 月 18 日
編集済み: Ameer Hamza 2020 年 5 月 18 日
Hi,
I have some 3D arrays, and I would like to obtain/create table for each dimension, I could do it but I wanna it to operate like in a for loop so it depends on how many dimension is the array,
Please any help, I am using MatLab 2016a
Also, how could I assign/change variable name :
Thanks,
clear all; clc; close all;
x(:,:,1)=1;
x(:,:,2)=2;
y(:,:,1)=3;
y(:,:,2)=4;
for i=1:2;
z(:,:,i)=table(x(:,:,i),y(:,:,i));
% x.Properties.VariableNames = {'x1','x2','y1','y2'};
end

回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 5 月 18 日
編集済み: Ameer Hamza 2020 年 5 月 18 日
Creating a 3D table is not yet allowed in MATLAB. Also, you cannot assign a table as an element of a simple array. A good way is to use a cell array where each of its cells contains a table.
x(:,:,1)=1;
x(:,:,2)=2;
y(:,:,1)=3;
y(:,:,2)=4;
z = cell(1,2);
for i=1:numel(z)
z{i}=table(x(:,:,i),y(:,:,i));
z{i}.Properties.VariableNames = {'x','y'};
end
You can then access the table values using variable names like this
z{1}.x % x column of first table
z{2}.y % y column of second table

カテゴリ

Help Center および File ExchangeTables についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by