필터 지우기
필터 지우기

[GUI] Importing Data from an array of strings

조회 수: 1 (최근 30일)
Shane
Shane 2012년 12월 18일
I have an array of strings:
listboxItems = cellstr( get(handles.listbox_dat, 'string') );
The array is a list of .dat files. "something.dat,etc.dat..."
I want to import a certain .dat file which for the purpose of this question is the value "a" in the array.
When I type the following it says "unable to open file"
importer = importdata(listboxItems(a));
The file is in the Matlab folder and I am able to import it via the main matlab command window. I also check with the aid of a "static text" to show listboxItems(a) with the following:
set(handles.text1,'string',listboxItems(a))
which shows "something.dat" and yet the next line that asks for that data to be imported it is unable to open the file. Because of the error I know that the string is "something.dat" and not just "something"
Anyways any help is greatly appreciated.
Thanks, Shane

채택된 답변

Walter Roberson
Walter Roberson 2012년 12월 18일
importer = importdata(listboxItems{a}); %note {}
  댓글 수: 1
Shane
Shane 2012년 12월 18일
Thank you soo much. I went to visit a friend to ask him to help, and he told me that the element from the listbox was delivering a cell and not the string itself and that either:
importer = importdata(listboxItems{a});
or
importer = importdata( char(listboxItems(a)) );
would work, but because as I log on now and see this correct answer you answer was accepted. <3
Thank you for your help.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by