assign header line value to variable
显示 更早的评论
I have a .vff file wich I open :
fid = fopen('test.vff');
The header is as follows:
ncaa;
rank=3;
type=raster;
format=slice;
bits=32;
bands=1;
size=256 256 256;
I want to extract size as a variable. So far I've tried:
size = fgetl(fid)
7 times in a row to get to the correct line, but the output I get is a char variable:
size =
'size=256 256 256;'
Instead of an array.
Thanks
CG
1 个评论
采纳的回答
更多回答(1 个)
A very simple and very efficient method without eval and without shadowing the inbuilt size:
>> str = 'size=256 256 256;';
>> vec = sscanf(str,'size=%f%f%f')
vec =
256
256
256
类别
在 帮助中心 和 File Exchange 中查找有关 Data Import and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!