Hi, I have a matrix name BS_channelTable of size (5,25) containg only zeros and ones. I want to print its element using a single fprintf command.
Just like if i just use the matrix name BS_channelTable in the command window.

7 Kommentare

per isakson
per isakson am 5 Jun. 2014
Why "fprintf"?
Aftab Ahmed Khan
Aftab Ahmed Khan am 5 Jun. 2014
because at the moment i have sorted it out like this, in my script editor. i am sure there will be some way to print it in more decent way, right ?
fprintf(1,'\nUpdated Base station channel table.');
BS_channeltable
Did you try DISP?
fprintf( 'My matrix is:\n' ) ;
disp( BS_channelTable ) ;
I am asking because you are using fid = 1 = stdout..
Star Strider
Star Strider am 5 Jun. 2014
To be fair, fid = 1 was my idea, with 1 as a default to be sure it worked.
Cedric
Cedric am 5 Jun. 2014
Well, it has also the advantage that we can display red font without CPRINTF, using 2 = stderr ;-)
Star Strider
Star Strider am 5 Jun. 2014
Thanks! I wasn’t aware of that.
Something else you taught me!
Cedric
Cedric am 5 Jun. 2014
Bearbeitet: Cedric am 5 Jun. 2014
I wouldn't recommend it as stderr should be kept for errors.. but if, like me, you make mistakes in most computations, then it can become legitimate to print to this stream ;-)

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Star Strider
Star Strider am 5 Jun. 2014

4 Stimmen

This works:
fid = 1; % Insert true ‘fid’
BS_channelTable = randi([0 1], 5, 25); % Create data
fprintf(fid, [repmat(' %d ', 1, 25) '\n'], BS_channelTable')

2 Kommentare

Aftab Ahmed Khan
Aftab Ahmed Khan am 5 Jun. 2014
Thanks strider,
nice to see you after few weeks.
Star Strider
Star Strider am 5 Jun. 2014
My pleasure!
Quite definitely you too!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Operators and Elementary Operations finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by