ComputerForum.com ComputerForum.com  

Go Back   Computer Forum > Computer Software > General Software

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 02-27-2011, 12:02 AM   #1
Bit Member
 
Join Date: Feb 2011
Posts: 2
Default In MATLAB, what syntax can I use to print out a blank line, and move to the next one?

I've programmed in C++ before, and I know exactly which function I would use to do this in C++. For example, in C++ lets say I wanted the program to simply display the following (disregarding the quotation marks, they are only there to seperate the desired output from the rest of the text I'm typing within this question) :



"This is the first line

This is the second line"


So to do this I would write the following code:

"
#include<iostream.h>

int main()
{
cout << "This is the first line" << endl << endl;
cout << "This is the second line " << end;
}

"

So, how can I get this to occur in matlab? What if I want to have the command window print out the following:

"
x = 100


y = 200

"

Note that I put 3 blank lines in between the two statements. I know that I could simply type "x = 100" then press enter, then type "y = 200", but... that doesn't give me the empty line I desire. Can somebody please help me out here? The reason I want to know this is so that on my homework that I have to hand in, I can make it look much neater by adding blank lines to seperate the different problems and such. Thanks in advance.

(P.S. I haven't written in C++ for over a year so I was just going off memory with respect to the syntax. My example probably contains errors, but please just ignore them. I'm not worried about weather or not my C++ syntax was correct, but rather that you get the point that I'm looking for the equivilant syntax for "endl" in Matlab)
mfetch22 is offline   Reply With Quote
Sponsored Links
Old 02-27-2011, 12:31 AM   #2
Petabyte Member
 
brian's Avatar
 
Join Date: Jun 2007
Location: Virginia
Age: 22
Posts: 5,348
Default

Quote:
Originally Posted by mfetch22 View Post
I've programmed in C++ before, and I know exactly which function I would use to do this in C++. For example, in C++ lets say I wanted the program to simply display the following (disregarding the quotation marks, they are only there to seperate the desired output from the rest of the text I'm typing within this question) :



"This is the first line

This is the second line"


So to do this I would write the following code:

"
#include<iostream.h>

int main()
{
cout << "This is the first line" << endl << endl;
cout << "This is the second line " << end;
}

"

So, how can I get this to occur in matlab? What if I want to have the command window print out the following:

"
x = 100


y = 200

"

Note that I put 3 blank lines in between the two statements. I know that I could simply type "x = 100" then press enter, then type "y = 200", but... that doesn't give me the empty line I desire. Can somebody please help me out here? The reason I want to know this is so that on my homework that I have to hand in, I can make it look much neater by adding blank lines to seperate the different problems and such. Thanks in advance.

(P.S. I haven't written in C++ for over a year so I was just going off memory with respect to the syntax. My example probably contains errors, but please just ignore them. I'm not worried about weather or not my C++ syntax was correct, but rather that you get the point that I'm looking for the equivilant syntax for "endl" in Matlab)
You can use \n for example "fprintf('This is an example\n of a new line\n\n ')"
brian is offline   Reply With Quote
Old 02-28-2011, 04:44 PM   #3
Bit Member
 
Join Date: Feb 2011
Posts: 2
Default

THANKS!!!!!! I really appreciate your post... you don't know how unreasonably hard it has been for me to find such a simple command. I've been searching through the internet for far too long. And finnally, I've made it to my answer. I thank you again, you've made my day. !!!!!!!!!!!!!!!!
mfetch22 is offline   Reply With Quote

Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Subnetting houssam_ballout Computer Networking and Servers 16 12-16-2005 09:53 AM


All times are GMT +1. The time now is 11:05 PM.


Powered by: vBulletin Version 3.8.7
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.6.0 ©2011, Crawlability, Inc.
Copyright © 2002-2014 Computer Forum