Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: with or without [] in fprintf usage
Replies: 1   Last Post: Oct 17, 2012 12:11 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Mike

Posts: 336
Registered: 4/17/07
with or without [] in fprintf usage
Posted: Oct 16, 2012 11:43 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi

I confuse to use fprintf when with or without [] as codes following:

A=magic(3)
>> B=zeros([3,3,2])

>> B(:,:,1)=A

>> B(:,:,2)=A+1
>> fprintf('%f %f\n',B(2,3,:),B(2,2,:))

7.000000 8.000000
5.000000 6.000000
>> fprintf('%f %f\n',[B(2,3,:),B(2,2,:)])
7.000000 5.000000
8.000000 6.000000
>> B(2,3,:),B(2,2,:)

ans(:,:,1) =

7


ans(:,:,2) =

8


ans(:,:,1) =

5


ans(:,:,2) =

6

>> [B(2,3,:),B(2,2,:)]

ans(:,:,1) =

7 5


ans(:,:,2) =

8 6


How to explain with or without [] in fprintf usage?
Thanks

Mike



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.