How can i get a pathname with \*.jpg for an image folder.

조회 수: 2 (최근 30일)
Nithya
Nithya 2014년 3월 24일
댓글: Marta Salas 2014년 3월 25일
I am using
1. folder_name = uigetdir('C:\Users\Student\Documents\MATLAB\matlab program folder')
2. dirNamev =('C:\Users\Student\Documents\MATLAB\matlab program folder\9.15\*.jpg');
filesv = dir(dirNamev);
to get the folder name, but form 1---> it gives me only "C:\Users\Student\Documents\MATLAB\matlab program folder\9.15". 9.15 is a folder containing set of 11 images. My aim is to get a 11x1 struct as in --->form 2. I want to go for 1st method because the folder may change every time and user may need to make a change. Please help me with some ideas.

채택된 답변

Jan
Jan 2014년 3월 24일
folder_name = uigetdir('C:\Users\Student\Documents\MATLAB\matlab program folder');
filesv = dir(fullfile(folder_name, '*.jpg'));
  댓글 수: 2
Nithya
Nithya 2014년 3월 25일
I got the files with this command.But i also require the pathname with file separator at the end to pass to function and i am nt able to get that. Is there a solution for that. i get this for folder name:
'C:\Users\Student\Documents\MATLAB\matlab program folder\9.15'
but can i get through some other command:
'C:\Users\Student\Documents\MATLAB\matlab program folder\9.15\'
Marta Salas
Marta Salas 2014년 3월 25일
you can concatenate the character '\':
folder_name = [folder_name '\'];
or you can do:
fullfile(folder_name, filesv(1).name)

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

추가 답변 (1개)

Chandrasekhar
Chandrasekhar 2014년 3월 24일
[fname, pname] = uigetfile({'*.jpg','*.jpeg'})

Community Treasure Hunt

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

Start Hunting!

Translated by