creating a table in matlab
Afficher commentaires plus anciens
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.
Réponses (4)
Youssef Khmou
le 25 Fév 2013
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
le 25 Fév 2013
Modifié(e) : Azzi Abdelmalek
le 25 Fév 2013
0 votes
Shaun VanWeelden
le 25 Fév 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))';
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
le 25 Fév 2013
0 votes
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.
Catégories
En savoir plus sur Data Type Identification dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!