improve flexibility of writedata

writedata requires me to know whether the thing I will be writing is string, integer or floating.

I want to write a matrix where the type of entries can vary.

Is there any way to do this with writedata?

Robert Israel's picture

fprintf

Use fprintf.  For example:

> A := << a^2| 3.5>, < 2 | b>>;
  fprintf("myfile.txt","%{c,}a\n", A);     
  close("myfile.txt");

and the file should contain:

a^2,3.5
2,b
 

thanks!

Thanks Robert!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}