Save all bands (1-336) of a multi-dimensional data in a structure array format

1 ビュー (過去 30 日間)
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.
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);
  2 件のコメント
Eberechi ICHI
Eberechi ICHI 2022 年 2 月 2 日
Yes thanks Walter, you are right. I meant I dataw data. I want to save it in a structure array for all the bands.



Walter Roberson
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])));
whos s
Name Size Bytes Class Attributes s 336x1 89491648 struct
ans = 1×2
416 640
  1 件のコメント
Eberechi ICHI
Eberechi ICHI 2022 年 2 月 3 日
Thanks Walter, it worked pretty well.


その他の回答 (0 件)


Find more on Multidimensional Arrays in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by