creating a table in matlab
2 views (last 30 days)
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.
Youssef Khmou on 25 Feb 2013
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 .
Shaun VanWeelden on 25 Feb 2013
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))';
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 on 25 Feb 2013
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.