首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Matlab学习札记[3](Using Script Files and Managing Data)

2012-10-08 
Matlab学习笔记[3](Using Script Files and Managing Data)3.1?INPUT TO A SCRIPT FILE3.1.1?The variable

Matlab学习笔记[3](Using Script Files and Managing Data)

3.1?INPUT TO A SCRIPT FILE

3.1.1?The variable is defined and assigned a value in the script file.

?

3.1.2?The variable is defined and assigned a value in the Command Window.

?

3.1.3?The variable is defined in the script file, but a specific value is entered?in the Command Window when the script file is executed

例如

variable_name = input(‘string with a message that?is displayed in the Command Window’)

?

3.2?OUTPUT COMMANDS

3.2.1?The disp Command

disp(name of a variable) or disp(‘text as string’)

?

3.2.2?The fprintf Command

1.Using the fprintf command to display text:

fprintf(‘text typed in as a string’)

?

2.Using the fprintf command to display a mix of text and numerical data

fprintf(‘text as string %-5.2f additional text’,variable_name)

fprintf(‘..text...%g...%g...%f...’,variable1,variable2,variable3)

?

3.Using the fprintf command to save output to a file:

?

a) Opening a file using the fopen command

fid = fopen(‘file_name’,‘permission’)

?

b) Writing the output to the open file using the fprintf command.

fprintf(fid,‘text %-5.2f additional text’,variable_name)

?

c) Closing the file using the fclose command.

fclose(fid)

?

3.2.3?THE save AND load COMMANDS

1 The save Command

save file_name and save(‘file_name’)

save file_name var1 var2 and?save(‘file_name’,‘var1’,‘var2’)

?

2?The load Command

load file_name or load(‘file_name’)

load file_name var1 var2 or?load(‘file_name’,‘var1’,‘var2’)

?

3.2.4 IMPORTING AND EXPORTING DATA

variable_name = xlsread(‘filename’)

variable_name = xlsread(‘filename’,‘sheet_name’)

variable_name = xlsread(‘filename’,‘sheet_name’,‘C2:E5’)

?

xlswrite(‘filename’,variable_name)

?

?

?

?

?

热点排行