how to display output in matlab as table enclosed below

조회 수: 345 (최근 30일)
work wolf
work wolf 2016년 9월 1일
댓글: Shreen El-Sapa 2021년 7월 29일
i have data as follows as
2 1 -0.307799 0.00
3 0.544459 0.0153522 0.01
4 0.566101 0.00070708 0.02
5 0.567143 -1.40255e-08 0.03
6 0.567143 1.50013e-12 0.04
7 0.567143 0 0.05
how to display output in matlab as table with the first row (enclosed below)
count x f(x) initial
2 1 -0.307799 0.00
3 0.544459 0.0153522 0.01
4 0.566101 0.00070708 0.02
5 0.567143 -1.40255e-08 0.03
6 0.567143 1.50013e-12 0.04
7 0.567143 0 0.05
  댓글 수: 1
Shreen El-Sapa
Shreen El-Sapa 2021년 7월 29일
How can I get data like this in matlab and put it in table?
I calculated function and I want to put it in tables for various parameters.
Thanks

댓글을 달려면 로그인하십시오.

답변 (2개)

Star Strider
Star Strider 2016년 9월 2일
You can do that using a regular table but you cannot use ‘f(x)’ as a variable name because it is not a valid MATLAB variable name. I have changed it to ‘fx’ here:
Data = [ 2 1 -0.307799 0.00
3 0.544459 0.0153522 0.01
4 0.566101 0.00070708 0.02
5 0.567143 -1.40255e-08 0.03
6 0.567143 1.50013e-12 0.04
7 0.567143 0 0.05];
VarNames = {'count', 'x', 'fx', 'initial'};
T = table(Data(:,1),Data(:,2),Data(:,3),Data(:,4), 'VariableNames',VarNames)
  댓글 수: 4
work wolf
work wolf 2016년 9월 4일
thank you , but i need to show in workspace as matrix , i.e, add name row (( size 1xn ))for every column in number matrix (( size mxn )) as V=[ w n u ] (size 1x3) ; M=[ 1 2 3; 4 5 6;7 8 9; 10 11 12] size(4x3). M=
Star Strider
Star Strider 2016년 9월 4일
My pleasure.
You can only do that with a table object, and you can only do that with R2013b or later.
Another option is:
DataCell = {VarNames, Data};
That puts all the variables in a cell array, but does not actually create a table. That’s as good as it gets without the table funciton.

댓글을 달려면 로그인하십시오.


Azzi Abdelmalek
Azzi Abdelmalek 2016년 9월 1일
h={'count' 'x' 'f(x)' 'initial'}
data=[2 1 -0.307799 0.00
3 0.544459 0.0153522 0.01
4 0.566101 0.00070708 0.02
5 0.567143 -1.40255e-08 0.03
6 0.567143 1.50013e-12 0.04
7 0.567143 0 0.05]
f=figure;
t=uitable(f,'data',data,'columnname',h)
  댓글 수: 1
work wolf
work wolf 2016년 9월 2일
Thank you, but how to display results in command window and workspace? because results display as figure!!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by