字符串:
字符串是由单引号引出,有一系列字符组成。MyText=‘Hello,World’;
如果字符串内包含单引号,用两个单引号表示。OtherText=‘You''re right ’; You're right .
两个字符串的连接,longText = [myText,'-',otherText] longtext=hello, world - You're right
将数字转换成字符,并与字符串连接,应用函数,比如:num2str or int2str
f=71; c=(f-32)/1.8; tempText = ['Temperature is ',num2str(c),'C'] Temperature is 21.6667 C
调用函数:
Matlab提供了大量的函数以实现计算功能,与其他编程语言的方法或子程序的功能是一样的。
例如:求最大值函数Max,A=[1 3 5]; max(A) ans=5,,如果有多个参数,用逗号分割B=[10 6 4];max(A,B) ans= 10 6 5
将结果输出至变量中:maxA=max(A);[maxA,location] = max(A);
显示字符串:disp('Hello world');
clc 清除窗口中的命令,clear 清除变量