フィルターのクリア

importdata: index exceeds matrix dimensions

1 回表示 (過去 30 日間)
Alex
Alex 2016 年 10 月 4 日
編集済み: Walter Roberson 2016 年 10 月 11 日
My script works fine on my personal computer at home running Matlab student 2010(a or b), but does not work on my machine at the College running MatLab 2012b.
"Index exceeds matrix dimensions." at rays=importdata(hnam{1});%rays=4; %%%%%FAILS HERE
clear all
% the data
proot='Plane.*';% FOLDER template
hroot='Data.txt'; % <- your FILENAME template
% the engine
d=dir(proot);
d={d([d.isdir]).name}.';
hnam=cellfun(@(x) sprintf('%s%s%s',x,filesep,hroot),d,'uni',false);
%%%%variable for number of traces
rays=importdata(hnam{1});%rays=4; %%%%%FAILS HERE
rays=rays(1,1);

回答 (2 件)

Marc Jakobi
Marc Jakobi 2016 年 10 月 5 日
It fails because there is probably no file or folder that matches 'Plane.*' in the current folder on your uni machine. So dir(proot) returns an empty cell.
  1 件のコメント
Alex Cushley
Alex Cushley 2016 年 10 月 11 日
Thanks for the suggestion, but I already checked that there was at least one file called Plane*. I had Plane1-Plane100 in the folder, but moved them to another directory and am using Plane101 as a test dataset for now. My working directory is: /home/cushley/Documents/MATLAB/test_B_para.
What do you mean by "uni machine"? I was working on a Windows box, but have now had it fail at the same line on both my Windows and Ubuntu workstations.
Cheers,
Alex

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


Alex Cushley
Alex Cushley 2016 年 10 月 11 日
I found my mistake. It should be "Plane*", not "Plane.*"
It was working on my other machine so I must have hit the "." button by accident at some point after transferring it to my other machine, hit "run" and that auto-saved the typo.
Best regards,
Alex

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by