3

I do this to output the contents of a string (and nothing more):

fprintf( '%s', my_str );

but it feels like I've missed a function that takes only my_str as an argument. Which function should I use?

2
  • disp might be an alternative but it doesn't give you much control over the output. mathworks.co.uk/help/matlab/ref/disp.html Commented Feb 25, 2014 at 10:01
  • disp is what I was looking for! For some reason I only checked display which is different. Commented Feb 25, 2014 at 10:02

2 Answers 2

3

disp is what you are looking for, as in:

>>disp string  %command format for single string arguments
string  
>>disp 'string test' 
string test
>>disp ('string test') %function format
string test

and for a variable

>> test= 'string';
>> disp(test)
string

but not

>>disp string test
Error using disp
Too many input arguments.

and you can always do this:

>> a = 'string';
>> a

a =

string
Sign up to request clarification or add additional context in comments.

Comments

1

Use DISP - disp(my_str)

Type "help disp" on MATLAB command line.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.