Borrar filtros
Borrar filtros

Creating multidimensional table from multidimensional array

17 visualizaciones (últimos 30 días)
Ali Tawfik
Ali Tawfik el 18 de Mayo de 2020
Editada: Ameer Hamza el 18 de Mayo de 2020
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

Respuestas (1)

Ameer Hamza
Ameer Hamza el 18 de Mayo de 2020
Editada: Ameer Hamza el 18 de Mayo de 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

Categorías

Más información sobre Tables en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by