In MATLAB, what syntax can I use to print out a blank line, and move to the next one?

Discussion in 'General Software' started by mfetch22, Feb 27, 2011.

  1. mfetch22

    mfetch22 New Member

    Messages:
    2
    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)
     
  2. brian

    brian VIP Member

    Messages:
    5,327
    You can use \n for example "fprintf('This is an example\n of a new line\n\n :)')"
     
  3. mfetch22

    mfetch22 New Member

    Messages:
    2
    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. :) :D :) :D :) :D:D:D:D:D:D:D:D:D !!!!!!!!!!!!!!!!
     

Share This Page