disp函数的介绍
disp(X)
displays the value of variableX
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
提示:以下是本篇文章正文内容,下面案例可供参考
一、相关MATLAB知识点学习
本次学习的目标 :主要学习disp函数及其基本操作
示例1: Create a variable with numbers and another variable with text.
输入: A = [15 150]; S = 'Hello World.'; disp(A) disp(S) 输出: 15 150 Hello World.
示例2: Display a matrix and label the columns as
Corn
,Oats
, andHay
.输入: X = rand(5,3); disp(' Corn Oats Hay') disp(X) 输出: Corn Oats Hay 0.8147 0.0975 0.1576 0.9058 0.2785 0.9706 0.1270 0.5469 0.9572 0.9134 0.9575 0.4854 0.6324 0.9649 0.8003
示例3 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 = "http://www.mathworks.com">MathWorks Web Site</a>'; disp(X) 输出: MathWorks Web Site
示例4 Display Multiple Variables on Same Line
输入: name = 'Alice'; age = 12; X = [name,' will be ',num2str(age),' this year.']; disp(X) 输出: Alice will be 12 this year.
输入: name = 'Alice'; age = 12; X = sprintf('%s will be %d this year.',name,age); disp(X) 输出: Alice will be 12 this year.
输入: name = 'Alice'; age = 12; fprintf('%s will be %d this year.\n',name,age) 输出: Alice will be 12 this year.
总结:
以上就是今天要讲的内容,本文仅仅简单介绍了字典的使用,并解决了二个数求和问题