필터 지우기
필터 지우기

Error using load Number of columns on line 4 of ASCII file " " must be the same as previous lines.

조회 수: 10 (최근 30일)
load('/Users/Kucharikgradcomp/Desktop/AgroIBIS_inputs/LULC_14_CAMPBELL.m')
indW = find(data(:,18)==1);
dataALL = zeros(53280,1); % grid cell, year, scenario
dataALL(:) = -9999;
i=1:53280;
Data1(indW,:,i) = LULCall(indW,:,i);
cTab = dlmread([foldN 'LULC_color_map.txt'],' ');
createMapPNG3(Data1(:),cTab,fName);

채택된 답변

Walter Roberson
Walter Roberson 2017년 6월 13일
Do not load() .m files. If they contain commands, then execute them, possibly with run() . If they contain data, then use a different file extension and an appropriate import routine.
load() of text files should only be used for rectangular numeric blocks that use space for the delimiter and either have no header at all or else use lines starting with % as the header.
You cannot use load() to read csv-type files
Note: if used save() to create the file and you did not use the -ASCII option at the time you saved, then the file would have been created as binary in mat file format even if you used .m as the file extension, but MATLAB would then expect text format when you tried to load the resulting file because of the .m extension. If you accidentally saved in mat file binary format to a .m file, then rename it to have .mat extension.
  댓글 수: 3
Stephen23
Stephen23 2019년 7월 30일
편집: Stephen23 2019년 7월 30일
@looking for answers: your file uses decimal commas. MATLAB only accepts decimal points.
Search this forum for discussions on how to import data with decimal commas.
looking for answers
looking for answers 2019년 7월 31일
Hi Stephen, thank you for your advice. Actually, I have a file where both comma + point are used as decimal delimiters. I think I will probably replace commas with points.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by