disp函数

Display value of variable

Syntax

disp(X)

Description

disp(X) displays the value of variable X without printing the variable name. Another way to display a variable is to type its name, which displays a leading “X =” before the value.

If a variable contains an empty array, disp returns without displaying anything.

Examples

Display Variable Values
Create a variable with numbers and another variable with text.
Display the value of each variable.

>> A = [15 150];
>> disp(A)15   150
>> S = 'Hello World.';
>> disp(S)
Hello World.

Display Matrix with Column Labels
Display a matrix and label the columns as Corn, Oats, and Hay.

>> disp('     Corn      Oats      Hay')Corn      Oats      Hay
>> X = rand(5,3);
>> disp(X)0.8147    0.0975    0.15760.9058    0.2785    0.97060.1270    0.5469    0.95720.9134    0.9575    0.48540.6324    0.9649    0.8003

Display Hyperlink in Command Window
Display a link to a Web page by including HTML hyperlink code as input to disp. For example, display a link to the MathWorks® Web site.

>> X = '<a href = "https://www.mathworks.com">MathWorks Web Site</a>';
>> disp(X)

MathWorks Web Site

Display Multiple Variables on Same Line
Here are three ways to display multiple variable values on the same line in the Command Window.

Concatenate multiple character vectors together using the [] operator. Convert any numeric values to characters using the num2str function. Use disp to display the result.

>> name = 'Alice';
>> age = 12;
>> X = [name,' will be ',num2str(age),' this year.'];
>> disp(X)
Alice will be 12 this year.

Use sprintf to create text, and then display it with disp.

>> name = 'Alice';
>> age = 12;
>> X = sprintf('%s will be %d this year.',name,age);
>> disp(X)
Alice will be 12 this year.

Use fprintf to directly display the text without creating a variable. However, to terminate the display properly, you must end the text with the newline (\n) metacharacter.

>> name = 'Alice';
>> age = 12;
>> fprintf('%s will be %d this year.\n',name,age);
Alice will be 12 this year.

MATLAB语言基础学习之disp函数相关推荐

  1. MATLAB语言基础学习之ls函数

    ls函数 List folder contents Syntax ls ls name list = ls(___) Description ls lists the contents of the ...

  2. Matlab中print, fprint, fscanf, disp函数的用法

    最近一直在用python,导致学习的一些函数就有点混淆,趁着这会儿看代码,就再回顾下Matlab中print, fprint, fscanf, disp函数的用法 一.print() 函数可以把函数图 ...

  3. matlab语言实验二,实验二 MATLAB语言基础

    实验二 MATLAB 语言基础 一.实验目的 基本掌握 MATLAB 向量.矩阵.数组的生成及其基本运算(区分数组运算和矩阵运算).常用的数学函数.了解字符串的操作. 二.实验内容 (1) 向量的生成 ...

  4. 01_Go语言基础学习_Golang语言特性、环境搭建、第一个Go程序、包

    1. Golang语言特性: 垃圾回收: 1.内存自动回收,再也不需要开发人员管理内存: 2.开发人员专注业务实现,降低了心智负担 : 3.只需要new分配内存,不需要释放 天然并发: 1.从语言层面 ...

  5. 《C语言基础学习笔记》—— 黑马程序员 <Part1-4>

    <C语言基础学习笔记 Part1-4> Part 1 基础介绍 1. 第一个C语言程序:HelloWorld 1.1 编写C语言代码:hello.c 1.2代码分析 1)include 头 ...

  6. C语言基础:数组作为函数参数传递演示源码

    将做工程过程中常用的内容片段记录起来,如下内容内容是关于C语言基础:数组作为函数参数传递演示的内容,应该能对小伙伴也有好处. #include <stdio.h>void show_arr ...

  7. python数据参数_零基础学习python数据分析——函数的参数

    原标题:零基础学习python数据分析--函数的参数 上一节课中我们讲了python的函数定义,Python的函数定义非常简单,但灵活度却非常大.除了正常定义的必选参数外,还可以使用默认参数.可变参数 ...

  8. java跳转控制语句有哪些_Java语言基础学习之流程控制语句和跳转控制语句实例分析...

    本文主要向大家介绍了Java语言基础学习之流程控制语句和跳转控制语句实例分析,通过具体的内容向大家展示,希望对大家学习JAVA语言有所帮助. 一.流程控制语句 在一个程序执行的过程中,各条语句的执行顺 ...

  9. matlab机器人工具箱学习笔记——ikine函数

    matlab机器人工具箱学习笔记--ikine函数 ikine函数用法 使用实例 链接: https://blog.csdn.net/weixin_42596724/article/details/8 ...

最新文章

  1. python代码画皮卡丘_Python气象绘图实例我们一起画台风(代码+数据)
  2. 基于USEARCH或QIIME绘制Alpha多样性稀释曲线(rarefraction curve)
  3. 重磅:国拨概算5.34亿!“新一代人工智能”重大项目项目申报指南发布
  4. HiveSQL运行优化参数配置
  5. 你在看Netflix,Netflix也在看你
  6. [html] 说说你对影子(Shadow)DOM的了解
  7. linux sftp密码错误,linux个别用户sftp坏掉,验证密码后卡住, 大概是什么问题?...
  8. 框架升级后某个类型所在程序集发生转移,应用还能正常运行吗?
  9. textswitcher_Android TextSwitcher和ImageSwitcher示例教程
  10. arima基本原理_单变量的ARIMA预测
  11. 【专题6: 其他知识】 之 【2.1.关于择业和就业_嵌入式学习路线和方法】
  12. linux 常用查看日志命令--more 命令
  13. python勾股数_勾股数-随心随性无为而为-51CTO博客
  14. python从0开始学编程第二天第19讲_少儿Python编程_第十九讲 数据分析网站
  15. linux和win10文件共享smb,Windows 10 Samba文件共享的设置方法,解决不能访问和密码错误的问题...
  16. 虚拟中3DMax2018打开报错
  17. check mk 监控 oracle
  18. Linux搭建邮箱服务器
  19. 多用户php商城源码,bymall B2B2C多用户开源商城系统 php版 v1.0.4
  20. mac上的ssh连接工具

热门文章

  1. 微信有声读物音频播放小程序系统设计与实现
  2. Adversarial Decomposition of Text Representation翻译
  3. 如何编写微信小程序的网络请求的代码
  4. 何以箫声默,默声箫以何?
  5. 网络营销工具电子邮件营销_改善电子邮件营销策略的5条提示
  6. 【ROS】Android开发环境搭建
  7. e63显示服务器忙,诺基亚E63开机提示正在安装以及设置gmail邮箱的问题
  8. Python 字符串分割split, 忽略括号里的分隔符(保留括号内容)
  9. Unity实现全景图
  10. 自动控制原理第5章——频率法(思维导图)