creating a table in matlab

1 次查看(过去 30 天)
maya
maya 2013-2-25
Hi,
I am new to matlab so pardon me if this question seems simple.
I have 6 vectors(they are number with decimals) and I am asked to display the first 3 rows of each vector in a table with a title for each vector. is there a simple way to do it, considering that I am not supposed to use loops.

回答(4 个)

Youssef  Khmou
Youssef Khmou 2013-2-25
hi maya,
this is not complete answer, so try to figure out how to print the 6 vectors :
we create 2 random vectors or lets say rand matrix and use 'disp' command :
>> disp(' test1 test2');disp(rand(2,2))
control the first 'disp' run to allign the output and put the 6 vects in one matrix .

Azzi Abdelmalek
Azzi Abdelmalek 2013-2-25
编辑:Azzi Abdelmalek 2013-2-25

Shaun VanWeelden
Shaun VanWeelden 2013-2-25
Without loops, there is no realllly simple way, that being said, there are a few shortucts, the code below should get you started:
vec=[41 56 87 90 24 25 0 52]
CellArray(2:4,1) = num2cell(vec(1:3))';
CellArray{1,1}='Vector 1'
I would check out the MATLAB help and some videos about cell arrays, honestly they can be a pain in the butt to learn for the first time, but once you do, they can be amazingly helpful. Let me know if you don't understand what's happening above!

Image Analyst
Image Analyst 2013-2-25
As yet another way, you could print them out using fprintf(). It really depends on what form your table takes and where it is supposed to be displayed, like on a GUI, in the command window, in a text file, etc.

类别

Help CenterFile Exchange 中查找有关 Numeric Types 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by