Save all bands (1-336) of a multi-dimensional data in a structure array format
1 次查看(过去 30 天)
显示 更早的评论
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/881185/image.jpeg)
Hello all, please i want to save any of the datad .dat doble output in a strutue format.
I want it to have all the 336 bands with the matrix order 416x640 for each of the band.
your assistcnae is highly anticipated.
Here is aexcerpt of my code.
clc
close all
clear all
infos = enviinfo('sample.hdr');
infow = enviinfo('White.hdr');
infod = enviinfo('Dark.hdr');
% Read the .raw data file
datas = multibandread('sample.raw',[infos.Height, infos.Width, infos.Bands],...
infos.DataType, infos.HeaderOffset, infos.Interleave, infos.ByteOrder);
dataw = multibandread('White.raw',[infow.Height, infow.Width, infow.Bands],...
infow.DataType, infow.HeaderOffset, infow.Interleave, infow.ByteOrder);
datad = multibandread('Dark.raw',[infod.Height, infod.Width, infod.Bands],...
infod.DataType, infod.HeaderOffset, infod.Interleave, infod.ByteOrder);
Thanks.
2 个评论
Walter Roberson
2022-2-2
Do you want to create a struct array with field named datad where each entry is 416 x 640, and the struct array would be 1 x 336 ?
Do you want to create a scalar struct with 336 different numbered fields each of which contains a 416 x 640 array?
Your output seems to suggest that possibly Dark.raw only contains a single 416 x 640 array. If that is not correct, if you think that Dark.raw contains 416 x 640 x 336 all in one file, then you need to investigate why it is saying 416 x 640 only. Your dataw shows that your general method is able to return a 416 x 640 x 336, so it would have to be something about the individual file for which infod.Bands is saying 1 instead of 336.
采纳的回答
Walter Roberson
2022-2-2
%example data to illustrate the function
dataw = randi([0 255], 416, 640, 336, 'uint8');
%the work
s = struct('dataw', squeeze(num2cell(dataw, [1 2])));
%check
whos s
size(s(1).dataw)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!