how to use uiopen

18 visualizaciones (últimos 30 días)
Andy
Andy el 7 de Oct. de 2011
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

Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 7 de Oct. de 2011
try a=uiimport
  2 comentarios
Andy
Andy el 11 de Oct. de 2011
i get a 1X1 cell that has the data i want in it, but how do i extract it?
Andy
Andy el 11 de Oct. de 2011
fixed it

Iniciar sesión para comentar.

Más respuestas (1)

Walter Roberson
Walter Roberson el 7 de Oct. de 2011
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 comentario
Andy
Andy el 11 de Oct. de 2011
this just gives me ans=0, i need to save whatever is opened in a variable

Iniciar sesión para comentar.

Categorías

Más información sobre Develop uifigure-Based Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by