3 views (last 30 days)

Show older comments

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);

Stephen
on 14 Jul 2016

This question is a continuation of these questions:

As has been commented many times, the simplest solution would be to call this FORTRAN code from MATLAB.

dpb
on 14 Jul 2016

Edited: dpb
on 14 Jul 2016

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.

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

Start Hunting!