MATLAB|常用语法tip

字符串

特殊字符插入

To Insert a . . . Use . . .
Single quotation mark ''
Percent character %%
Backslash \
Alarm \a
Backspace \b
Form feed \f
New line \n
Carriage return \r
Horizontal tab \t
Vertical tab \v
Hexadecimal number, N \xN
Octal number, N \N

格式化字符串输出

formatSpec = '构件尺寸为bxh = %dx%d mm,采用%s混凝土和%s钢筋';
A1 = 400;
A2 = 600;
A3 = 'C30';
A4 = 'HBR400';
str = sprintf(formatSpec,A1,A2,A3,A4);

图像技术

颜色

MATLAB|常用语法tip_第1张图片

线型符号

MATLAB|常用语法tip_第2张图片
mark

截图保存

x = linspace(0,2*pi,100);
y = sin(x);
figure
plot(x,y,'-*')
set(gcf,'color','w','units','centimeter')            % 获取尺寸使用get(gcf,'Position')
set(gcf,'Position',[1 1 8 8])
print(gcf,'-djpeg','test.jpg') 

文件打开

.m Open in MATLAB Editor.
.mat Return variables in structure st when called with the syntax:
st = open(name)
.fig Open figure in Handle Graphics®.
.mdl or .slx Open model in Simulink.
.prj Open project in the MATLAB Compiler Deployment Tool.
.doc* Open document in Microsoft® Word.
.exe Run executable file (only on Windows® systems).
.pdf Open document in Adobe® Acrobat®.
.ppt* Open document in Microsoft PowerPoint®.
.xls* Start MATLAB Import Wizard.
.htm or .html Open document in MATLAB browser.
.url Open file in your default Web browser.

匿名函数构造

fun_beta1 = @(x) x(1)^2+x(2);
fun_beta1([1,2])

你可能感兴趣的:(MATLAB|常用语法tip)