read specific values and ignore them using fread

2 次查看(过去 30 天)
Hello!
So I'm trying to find a way to read from a matrix of size 1x2000 the values that are assigned in positions 750 to 834 using the fread command.
Basically I open the given file that I want to read,using the command:
fid=fopen('Alien_Message');
im_1=fread(fid,251,'uint8'); %read the main header of the file and the line header and toss them away
im_2=fread(fid,[],'uint8'); %This is the part where I want to read the 750 to 834 bitstream and toss them away
Any idea on how can I manage this?

采纳的回答

yanqi liu
yanqi liu 2022-3-31
yes,sir,may be use loop to make it,but the result should be check,such as
fid=fopen('Alien_Message');
im_1=fread(fid,251,'uint8'); %read the main header of the file and the line header and toss them away
im_2 = [];
for i = 1 : 834
tmp = fread(fid,1,'uint8');
if i >= 750
im_2 = [im_2 tmp];
end
end
  3 个评论
Nick Vasilakis
Nick Vasilakis 2022-3-31
I can't load the file to the forum because the website does not give me the permission. Yet, this is the graph that I use to recompose the
Nick Vasilakis
Nick Vasilakis 2022-3-31
if i run the program giving im_raw the dimension that I see from workspace (1743,1) it returns me this error:
Index in position 1 exceeds array bounds. Index must not exceed 1.
Error in den_katalabainw_xristo (line 98)
im=im_raw(1743,1); %here are supposed to be entered the values of the final matrix for the image

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by