Getting an error while using evalin

13 ビュー (過去 30 日間)
anjori dutta
anjori dutta 2014 年 1 月 15 日
コメント済み: anjori dutta 2014 年 1 月 15 日
I am trying to uigetfile in GUIDE. In the .m file, I have this piece of code
function pushbutton1_Callback(~, ~, handles)
filename=uigetfile('*.*','Select a File to Parse');
set(handles.Filename,'String',filename);
evalin('base',['load ' filename]);
C1 = textread(filename, '%s','delimiter', '\n');
I am trying to get the filename in the workspace so that I can use in this part
"C1 = textread(filename, '%s','delimiter', '\n');"
But the error I am getting is
Error using ==> load
Number of columns on line 10 of ASCII file C:\Users\zz21wz\Desktop\xxx.ASC
must be the same as previous lines.
Error in ==> SimpleGUI>pushbutton1_Callback at 86
evalin('base',['load ' NAME]);
Please help

回答 (1 件)

Walter Roberson
Walter Roberson 2014 年 1 月 15 日
This does not have to do with evalin() and instead has to do with the fact that the text file is not consistent in how many columns it has per line.
If what you want to do is textread(), then why are you using the load ? load does not help you get the file name. You already have the file name: it is in "filename".
  1 件のコメント
anjori dutta
anjori dutta 2014 年 1 月 15 日
Hi Walter,
I tried textscan, textread...I get the error
??? Error using ==> load Unable to read file Jeep_UC_1_T1.ASC: No such file or directory.
So whats your suggestion to copy the filename into workspace so that I get use in
"C1 = textread(filename, '%s','delimiter', '\n');"

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT Files についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by