How to save .mat file as a variable to load for later?

1 回表示 (過去 30 日間)
Hung Mach
Hung Mach 2016 年 6 月 23 日
回答済み: Titus Edelhofer 2016 年 6 月 23 日
I have a .mat file consisting of essentially a couple hundred images. I'd like to pull out a single uint16 array for an image from that mat file and save it as a variable, for instance 'q'. So when I load that single file it would show up as 'q' on my workspace. How would I do that?

回答 (1 件)

Titus Edelhofer
Titus Edelhofer 2016 年 6 月 23 日
Hi,
use the functional form of load. Let's say the images in your .mat file are stored as variables im1, im2, im3, ... then you can read one into a variable q as follows:
% read im1 from file
data = load('myfile.mat', 'im1');
% and assign to q:
q = data.im1;
Titus

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT-Files についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by