How to add "for loop"

조회 수: 2 (최근 30일)
Tousif Ahmed
Tousif Ahmed 2017년 4월 18일
댓글: Rik 2017년 4월 18일
in workspace i have "dinfo" having 11x1 struct as shown in figure, i want to access "name" as it has images in it, after reading that, need to convert it into double format for each image and storing that in a folder as "dataset.mat", can anyone please help me with the code please. Thank You
  댓글 수: 3
Tousif Ahmed
Tousif Ahmed 2017년 4월 18일
I didn't understand the part which you explained so i changed the question so that some other can understand what i have asked. Thank You
Rik
Rik 2017년 4월 18일
If you don't understand an answer, ask for clarification. By opening multiple questions that are essentially the same, you don't really generate goodwill. I think you should really start a tutorial to get to know the Matlab basics. I'm sure there are many of them in whatever language you prefer.

댓글을 달려면 로그인하십시오.

채택된 답변

Rik
Rik 2017년 4월 18일
You're in luck. I usually ignore questions that don't show that the person asking has followed the advice from the question guide.
Images=cell(1,2);%pre-allocate a column-vector in the cell format
for n=1:length(dinfo)
position=str2double(dinfo(n).name(1:(end-4)));%convert the filename to a number
Images{position}=im2double(imread(dinfo(n).name));%read the image, convert to double and save in the cell
end
  댓글 수: 4
Jan
Jan 2017년 4월 18일
@Tousif: Please post the relevant code and the complete error message.
Tousif Ahmed
Tousif Ahmed 2017년 4월 18일
clc; clear all; %%
dinfo = dir('*.jpg');% image extension
%images=cell(1,2);%pre-allocate a column-vector in the cell format for n=1:length(dinfo) position=str2double(dinfo(n).name(1:(end-4)));%convert the filename to a number images{position}=double(imread(dinfo(n).name));%read the image, convert to double and save in the cell
end
I have 50 training
images of size 27x18, 4 test images of same size
example :if u type "load wine_database.mat", we get training and test in double format, i need the images to be in that format so that i can use it for "nprtool/nntool"
</matlabcentral/answers/uploaded_files/75443/wine.PNG>. I need in the format as shown in the reference image. I hope you are understanding what i am asking you

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by