Why am I getting "Dimensions of matrices being concatenated are not consistent." after 53 successful reads?
조회 수: 1 (최근 30일)
이전 댓글 표시
I'm puzzled about this error message after 53 successful reads using the same setup. "Spoiler" inputs print out as "2nd Control Surface" inputs. I've made certain that the input (from an old FORTRAN card deck) has separators (',' or ' ' ), but suddenly it stops working. Also, I did not ask to skip any lines of input.
-.0014 -.0008 -.0153 -.0187 -.0063 -.0207 -.012 -.0064 -.0052 -.0046 SPOILER,ALSP
-.0009 .00123 .0014 -.00085-.00438 .0058 .00295 .00297 .0063 .00838 INPUTS,CMSP
.001 0 0 0 0 0 0 0 0 0 2ND CONTROL,ALFLAP
.001 0 0 0 0 0 0 0 0 0 SURFACE,CMFLAP
fmt_num1='%7f%7f%7f%7f%7f%7f%7f%7f%7f%7f'; % 10F7.0
fgetl(fid);
XYc=textscan(fid,fmt_num1,1);
XY=cell2mat(XYc); % line 373
for i=1:L
ALSP(i)=XY(i);
end
Error using cat
Dimensions of matrices being concatenated are not consistent.
Error in cell2mat (line 75)
m{n} = cat(2,c{n,:});
Error in CNSMTX (line 373)
XY=cell2mat(XYc);
채택된 답변
dpb
2016년 7월 14일
편집: dpb
2016년 7월 14일
It fails after the 53rd record because the format changes...
...
49 8.5713 7.0532 6.9459 6.6719 6.915 6.9 6.9 7.4086 9.703 10.7462 M0
50 .0193 .0248 .0414 .003 .0073 .0198 .031 .0249 .0097 .0081 ALPHA
51 -.06 -.0490 -.0526 -.0564 -.0294 -.0384 -.0315 -.0218 -.0138 -.0115 CM0
52 .0913 .0843 .0814 .0608 -.0858 -.1498 -.1954 -.2034 -.2603 -.3058 DCMDCL7
53 0.0 TMACH=0
54 -.0014 -.0008 -.0153 -.0187 -.0063 -.0207 -.012 -.0064 -.0052 -.0046 SPOILER
55 -.0009 .00123 .0014 -.00085 -.0044 .0058 .00295 .00297 .0063 .00838 INPUTS
56 .000 0 0 0 0 0 0 0 0 0 2ND CONTROL
57 .000 0 0 0 0 0 0 0 0 0 SURFACE
58 .5 0 0 THRPIT°
59 .10 1
60 -.00200 .0665-.00100 .0292
61 -.00340 .0716-.00140 .0292
...
Where I added the line numbers before the records. This includes the header line in the count. Note the group line 49ff is four records of 10 followed by 1 record of one. That's the preceding pattern as well but beginning at record 54 there are the four records but then there's a record of three before the single entry; a different pattern.
After that, the pattern changes again.
Glancing at the m-file, it appears you've done precisely what I recommended most strongly against in trying to literally write the Fortran code in Matlab--instead, spend the time on either Walter's or my suggestions and you'll come out far ahead; I really don't see if you have the existing files why not just use the Fortran with a Matlab wrapper...
Alternatively, if you're adamant on moving the application entirely to Matlab, write it in Matlab from scratch using the features that make Matlab what it is--vectorize the operations and convert the input files into something that can be easily handled with the C i/o routines that are the basis for Matlab's formatted i/o. What you'll end up on the route you're currently embarked upon will be a nightmare going forward for any purpose.
댓글 수: 4
Walter Roberson
2016년 7월 14일
parsing is still beyond my skill level as a Student user
Earlier, I posted code that only needed to have the vector of field widths adjusted, and which would automatically create the appropriate format and convert the fields to numeric. You decided not to use it, and then spent the next several days continuing to try to solve the same difficulties that my code would have had no trouble with. :(
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Fortran with MATLAB에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!