MATLAB outputting a response

Posted on 2011-04-27
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

    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

    Thanks, perfect answer

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Add mobile access to browser application 3 108
    Visual xHarbour 1 48
    How Complex Is This Java Course ? 9 51
    array220 challenge 8 31
    Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
    The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

    730 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now