Questions about the unsure range in xlsread, when using gui
1 回表示 (過去 30 日間)
古いコメントを表示
When using gui to input the number of the column and row to confirm the range of the xlsread, but i am not sure how to combine it. the code is following,
serial1 = str2num(get(handles.location1,'String'));
serial2 = str2num(get(handles.location2,'String'));
col = char('B' + serial1);
row = char('D' + serial2);
location = (col:row);
rawname = handles.rawname;
%fullname = handles.fullname;
r_DATA = xlsread(rawname,'sheet1',location);
After running the code, it shows
Error using xlsread (line 260)
Data range 'FGHIJKLMNOPQRSTUVWXYZ[\]' is invalid.
Error in app>pushbutton2_Callback (line 410)
r_DATA = xlsread(rawname,'sheet1',location);
It is confused with the location
0 件のコメント
採用された回答
Jan
2019 年 3 月 20 日
編集済み: Jan
2019 年 3 月 20 日
I guess you mean:
col = sprintf('B%d', serial1);
row = sprintf('D%d', serial2);
location = [col, ':', row];
or simpler:
location = sprintf('B%d:D%d', serial1, serial2);
In your code 'B' + serial1 seems to be the character 'F' and 'D' + serial2 the character ']'. Then
'F':']'
is 'FGHIJKLMNOPQRSTUVWXYZ[\]'
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!