Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print matrix values in octave using printf

Tags:

matrix

octave

Suppose I have a matrix A=[1,2] if I try to print it with command

fprintf("A ", A) 

Output

A

Blank A is printed without values?

like image 234
Anks Avatar asked Mar 09 '23 22:03

Anks


1 Answers

It's:

fprintf('A:\n');
fprintf('%f\n', A);

You need to specify a valid format specifier when displaying a variable. Doing %f\n will print out a single value per line. Please read up on how to use format specifiers from the docs: https://www.gnu.org/software/octave/doc/v4.0.0/Formatted-Output.html#XREFsprintf

like image 72
rayryeng Avatar answered May 10 '23 00:05

rayryeng