[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


MATLAB outputting a response

Posted on 2011-04-27
Medium Priority
Last Modified: 2016-03-02
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
Question by:bhession
LVL 15

Accepted Solution

yuk99 earned 500 total points
ID: 35483802
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:

Author Closing Comment

ID: 35487962
Thanks, perfect answer

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
When you discover the power of the R programming language, you are going to wonder how you ever lived without it! Learn why the language merits a place in your programming arsenal.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses
Course of the Month20 days, 7 hours left to enroll

868 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question