Results in table format in Matlab

Asked

Viewed 8,510 times

0

When simulating a program in Matlab, it is possible to present the results in table format?

Output of the program:

Nível de tensão (V): 200.6000 199.5000 231.1000 198.8000 200.6000 200.4000 
Data e hora: 21-Aug-2014 18:06:00 23-Aug-2014 18:06:00 24-Aug-2014 06:06:00 27-Aug-2014 08:36:00 29-Aug-2014 14:21:00 30-Aug-2014 07:36:00 

Desired format:

Data e hora                 Tensão
20-Aug-2014 09:15:00         225
20-Aug-2014 09:30:00         222
  • 1

    @Omni thanks for the suggestion. I already edited my question.

  • @Omni is just that.

  • The vectors 'Voltage' and 'Date and time' have 200 positions each. I would like to present the results one column next to the other, but as I could not, first print the vector 'Date and time' and below the vector 'Voltage'.

  • See the reply from @Wanderson, do what you want.

  • Unfortunately the version of Matlab I am using does not have the Table command.

  • which version of Matlab you are using?

  • Matlab 7.12.0 (R2011a)

Show 2 more comments

2 answers

1

You can use the table command in order to not only tabulate the data but also store it in a tabular form.

Ex.:

T = table([’M';'F';’M'],[45;32;34],... {'NY';'CA';'MA'},logical([1;0;0]),... 'Variablenames',{'Gender' 'Age' 'State' 'Vote'})

T =

Gender    Age    State    Vote 
______    ___    _____    _____

M         45     'NY'     true 
F         32     'CA'     false
M         34     'MA'     false

More details can be obtained from the help of the command table.

1

Long live.

See the following example.

resultados = {'Data e hora','Tensão'};
resultados{2,1} = '20-Aug-2014 09:15:00';
resultados{2,2} = '225';
resultados{3,1} = '20-Aug-2014 09:30:00';
resultados{3,2} = '222';
resultados

Then just use an index to automatically control the line where you will add new data, IE,

resultados{i,1} = 'NOVA_DATA';
resultados{i,2} = 'NOVA_TENSAO';

I hope I’ve helped ;)

PS(1):

Does it do what it wants?

datas = ['1';'2';'3'];
tensao = [1,2,3];
resultados = {'Data e hora','Tensão'};
for i=1:size(datas,1)
      resultados{i+1,1} = datas(i);
      resultados{i+1,2} = tensao(i);
end
resultados
  • 'Date and time' and 'Pressure' are vectors of 200 positions, in this case, what should I do to print the results in table format?

  • I think Wanderson’s answer answers your question. If you don’t answer, explain a little better.

  • But the Matlab version I use does not have the Table function. (Matlab 7.12.0 (R2011a))

  • Do you need the data in a table or just want to print the data in table format? In any case see PS(1) in the main post.

  • I just have to print the data in table format.

  • Have you tried my method? I think it works for your case but only you can say it!

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.