Matrix help

3 次查看(过去 30 天)
Daniel
Daniel 2011-4-14
I have a matrix of letters, however in the command window the letters all have e.g 'B/H' instead of just B/H. my code at the moment is
function dissertationmatrixletters
C = cell(16);
for i=1:2:3
C(i,2)={'-B/H'};
end
for i=1:2:3
C(i+4,2)={'B/H'};
end
disp(transpose(C));
Does anybody know how to do this?
Kind Regards
Dan

采纳的回答

Matt Tearle
Matt Tearle 2011-4-14
If it's just a matter of how it's displayed:
fprintf([repmat('%4s ',1,16),'\n'],C{:})
(Note, you normally need to transpose before using fprintf, but you were displaying the transpose anyway, so I left it as C, rather than doing C=C'; first)

更多回答(2 个)

Oleg Komarov
Oleg Komarov 2011-4-14
The apostrophes just indicate that you're using a cell array to store elements.
If you access the content of the cell, you'll get B/H (w/o the apostrophes).
It depends what you need the array for. For printing purposes you could store:
A = [' B/H -B/H'
'-B/H B/H'];
But then it's a 2 by 10 char array.

Walter Roberson
Walter Roberson 2011-4-14
I discussed the solutions in your Letters In Matrix posting.
  2 个评论
Oleg Komarov
Oleg Komarov 2011-4-14
I just read it...Why would anybody care about the apostrophes in the command window?
Walter Roberson
Walter Roberson 2011-4-14
Look, are you here for the beer or are you here to ask questions?

请先登录,再进行评论。

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by