matlab如何新建mat文件,如何在Matlab中创建.mat文件?

I have 25 images in a folder and I want to make a .mat file for a road-sign recognition system.

What are the steps for making a .mat file in Matlab?

解决方案

There may be a better approach for images but here is what I know. If you want to control what goes into the .mat file you can specify what variables in your workspace will be saved using the save command.

% MATLAB R2017a

X = rand(273,273);

Y = rand(273,273);

Z = rand(273,273);

save FileName X Y Z

This creates a file FileName.mat.

You can access the contents using the load command.

clear

load FileName

To save everything in the workspace to a .mat file, use the save command without specifying the variables to save (MATLAB will then save them all).

W = rand(273,273);

save FileName

See the linked documentation for more options and examples.

This requires you to loop through the images in the folder. A direct approach to this is directly loading the images using a loop over [filepath 'image' num2str(j) '.jpg'] with index j where filepath = 'C:\Users\user1\Folder\ImageFolder\'. This uses string concatenation and the num2str command.

If you need to change your current directory within the script,the cd function is useful.

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值