Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2024.1.0 - Русский


struct2table

convert a struct into a table

Syntax

t = struct2table(st)
t = struct2table(st, Name, Value)

Arguments

st

scalar structure or array of structures

Name, Value

Name: 'VariableNames', Value: vector of strings: the variable name of each column of t. The variable names must be unique and their number must be equal to size(m, 2). Default value: ["Var1", ..., "VarN"].

Name: 'RowNames', Value: vector of string: the row names for t. The names must be unique and their number must be equal to size(m, 1). Default value: [].

t

table object

Description

struct2table converts a struct into a table. Each fieldnames of st becomes a variable name of t.

Like table function, you can specify the variable and row names thanks to optional parameters.

You can use directly t = table(st).

Examples

t = struct2table(st)

st.Code = ["AF"; "NA"; "OC"; "AN"; "AS"; "EU"; "SA"];
st.NameContinent = ["Africa"; "North America"; "Oceania"; "Antarctica"; "Asia"; "Europe"; "South America"];
st.Area = [30065000; 24256000; 7687000; 13209000; 44579000; 9938000; 17819000];
st.NumberCountry = [54; 23; 14; %nan; 47; 45; 12]; 
st.LifeExpectancy = [60; 78; 75; %nan; 72; 75; 74];
t = struct2table(st)
// or table(st)

a = struct("a", 1, "b", 2);
a = [a struct("a", 3, "b", 4)];
t = struct2table(a)
// or table(a)

t = struct2table(m, "RowNames", val)

st.Code = ["AF"; "NA"; "OC"; "AN"; "AS"; "EU"; "SA"];
st.NameContinent = ["Africa"; "North America"; "Oceania"; "Antarctica"; "Asia"; "Europe"; "South America"];
st.Area = [30065000; 24256000; 7687000; 13209000; 44579000; 9938000; 17819000];
st.NumberCountry = [54; 23; 14; %nan; 47; 45; 12]; 
st.LifeExpectancy = [60; 78; 75; %nan; 72; 75; 74];
t = struct2table(st)
t.Properties.RowNames = t.Code;
t.Code = [];

Code = ["AF"; "NA"; "OC"; "AN"; "AS"; "EU"; "SA"];
st.NameContinent = ["Africa"; "North America"; "Oceania"; "Antarctica"; "Asia"; "Europe"; "South America"];
st.Area = [30065000; 24256000; 7687000; 13209000; 44579000; 9938000; 17819000];
st.NumberCountry = [54; 23; 14; %nan; 47; 45; 12]; 
st.LifeExpectancy = [60; 78; 75; %nan; 72; 75; 74];
t = struct2table(st, "RowNames", Code)
// or table(st, "RowNames", Code)

See also

  • table — create a table from variables
  • table2struct — convert a table into a struct

History

ВерсияОписание
2024.0.0 Introduction in Scilab.
Report an issue
<< rowfun Timeseries/Table synchronize >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Mon Jun 17 17:55:12 CEST 2024