MATLAB outputting a response

Im new to MATLAB, still getting around the basic commands. Say you have the below, and I want to output the Matrix A or output the value of Q1. Or any other variable. Something like C++ cout of javas System.out.println functions.

%Krylov example

% state space
A=[-3 1 0 0;1 -3 1 0;0 1 -3 1; 0 0 1 -2];
C=[1 0 0 0];

% matching moments at infinity
Who is Participating?
yuk99Connect With a Mentor Commented:
If you omit the semicolon (;) from the end, the output will be on the screen. You can just type the variable name and hit Enter.

Another way is DISP function. Type disp(A) or disp(Q1).

For more sophisticated output you can use SPRINTF function:
disp(sprintf('Q1 value is %d\n', Q1))

For more information see SPRINTF doc:
bhessionAuthor Commented:
Thanks, perfect answer
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.