Garrison Peacock
Garrison Peacock

Reputation: 1

How to print piecewise functions in GNU Octave

How does one print out a piecewise function in GNU Octave in a human readable way?

Somehow produce output similar to this in either the console or a file: x^(4) + x^(3) + x^(2) + x + 1 for each polynomial in the piecewise function.

Upvotes: 0

Views: 343

Answers (1)

Siva Srinivas Kolukula
Siva Srinivas Kolukula

Reputation: 1251

You can use fprintf in MATLAB to write the polynomial you want into a file. Check the below code:

str = 'x^(4) + x^(3) + x^(2) + x + 1' ;
fid = fopen('check.txt','w') ;
fprintf(fid,'%s\n',str) ;
fclose(fid) ;

Upvotes: 0

Related Questions