1

I have an m*6 matrix in matlab and I want to display it in a string without the whitespace and the semicolons. I used the mat2str function but the output would e like that [1 2 3; 4 5 6; ...] . Is there any function or effecient way to prduce a string with no whitespace and semicolons ?

Kind Regards,

1
  • I doubt there is library code to do this. You are going to have to write something to loop over every row, every column and print out the value. Commented Sep 2, 2011 at 10:23

1 Answer 1

5
str = sprintf('%d', mtx);
Sign up to request clarification or add additional context in comments.

3 Comments

thnx Oli, is there any specific reason for choosing %d ?
@Momo: Only that the values in your example appeared to all be integers. Take a look at the format specifiers in the manual (mathworks.co.uk/help/techdoc/ref/sprintf.html), and experiment to find what works best for you.
@OliCharlesworth: maybe you should add a space '%d ' so that the different numbers are actually separated?

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.