Azzera filtri
Azzera filtri

Creating multidimensional table from multidimensional array

17 visualizzazioni (ultimi 30 giorni)
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

Risposte (1)

Ameer Hamza
Ameer Hamza il 18 Mag 2020
Modificato: Ameer Hamza il 18 Mag 2020
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

Categorie

Scopri di più su Tables in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by