Labeling a Piece of Data

I imported a txt file which gave me two columns. Well the top left number needs to be give a label/name(need to display and label it). How would I go about doing this? I have only had matlab for about 3 days. I have gained a slight grasp, but not even close to using it effectively obviously.
Thanks in advance.

Respuestas (1)

Walter Roberson
Walter Roberson el 5 de Oct. de 2012

0 votos

There is no way to label or name a number in MATLAB. MATLAB numeric arrays are purely numeric.
Perhaps you are looking for MATLAB's dataset objects?
Or perhaps you are looking to display the numbers as text in the command window, with a header line (or header column) ?
Or perhaps you are looking to make a table in a graphics window, such as with uitable()?
Or perhaps you are wanting to generate an HTML table from the numbers and view it in a browser?

5 comentarios

Tyler
Tyler el 5 de Oct. de 2012
Editada: Walter Roberson el 6 de Oct. de 2012
well, i imported a set of data, and need to label and display a number from the data.
say the data read
2342 8768
2654 0796
9703 1727
i need to label 2342 and display it.
Walter Roberson
Walter Roberson el 6 de Oct. de 2012
Display how ? And what do you mean by "label" in this context ?
Image Analyst
Image Analyst el 6 de Oct. de 2012
Editada: Image Analyst el 6 de Oct. de 2012
Here, try this:
m = [2342 8768
2654 0796
9703 1727];
for k = 1 : numel(m)
if k == 1
fprintf('%d <=== Look there is 2342, and this is its label!\n', m(1));
else
fprintf('%d\n', m(k));
end
end
In the command window:
2342 <=== Look there is 2342, and this is its label!
2654
9703
8768
796
1727
This code also seems rather effective:
rectangle('Position', [.1 .1 5 3]);
axis equal;
patch([.1 5.1 5.1 .1], [2 2 3.1 3.1], [.3 .5 .6]);
text(0.9, 2.5, 'Hello, my name is', 'FontSize', 30);
text(1.8, 1.1, '2342', 'FontSize', 50, 'Color', 'b');
axis off;
Walter Roberson
Walter Roberson el 6 de Oct. de 2012
I would call that an annotation rather than a label, but the difference between those is admittedly not clear.
Image Analyst
Image Analyst el 6 de Oct. de 2012
Editada: Image Analyst el 6 de Oct. de 2012
See my edit where I added the label code at the end. It should be clear that that is a label.

Iniciar sesión para comentar.

Categorías

Etiquetas

Preguntada:

el 5 de Oct. de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by