how to use uiopen

조회 수: 2 (최근 30일)
Andy
Andy 2011년 10월 7일
I was trying to do
a=uiopen
but it doesnt work. i want a variable to be equal to whatever i open. In this case, the file i open is a 454X1 list of doubles. Thanks

채택된 답변

Fangjun Jiang
Fangjun Jiang 2011년 10월 7일
try a=uiimport
  댓글 수: 2
Andy
Andy 2011년 10월 11일
i get a 1X1 cell that has the data i want in it, but how do i extract it?
Andy
Andy 2011년 10월 11일
fixed it

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2011년 10월 7일
You cannot do that with uiopen. Instead use uigetfile() and an appropriate method based upon the variety of file that was selected (e.g., imread(), load(), textscan(), etc.)
[pathname,dirname] = uigetfile();
fullpath = fullfile(dirname,pathname);
fid = fopen(fullpath,'rt');
datacell = textscan(fid,'%f');
fclose(fid)
a = datacell{1};
clear fullpath fid datacell
This sample code makes no attempt to protect you from the user asking to open (say) a PDF file... but neither did your original code.
  댓글 수: 1
Andy
Andy 2011년 10월 11일
this just gives me ans=0, i need to save whatever is opened in a variable

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

카테고리

Help CenterFile Exchange에서 App Building에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by