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)

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值