Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Problem with fileread when used in the code but when used all by itself it works. Why?

1 visualización (últimos 30 días)
Hi,
I have an output file that I am trying to read and scan for a certain phrase. If that phrase is in the output file then the loop in my code can continue. If not I want to terminate it. The phrase is 'TWOPNT: SUCCESS'. This is the code I have as of now:
Pattern = 'TWOPNT: SUCCESS'
A = fileread('OppDiff_HTPB_N2O.out')
B = strfind(A,Pattern)
empty = [] %what B will spit out an empty matrix if the pattern is not
%found in the file
if isequal(size(empty), size(B))
disp('No TWOPNT success found...may be a convergence problem')
error_message = 'No TWOPNT: SUCCESS found'
break
else %if the B matrix is not empty
disp('TWOPNT appears to have been successful! Conitnuing...')
endif
I made this part of my code and ran it by itself and it worked fine. However when I went to input it into my overall code it gets to this section and it goes to the fileread and spits out A=>> and stops working. Is there a certain size limit? If so why did it work when I used it outside of the code but not in it? Thanks.
  2 comentarios
Paige Nardozzo
Paige Nardozzo el 8 de Dic. de 2015
Sorry this is the code
Pattern = 'TWOPNT: SUCCESS'
A = fileread('OppDiff_HTPB_N2O.out')
B = strfind(A,Pattern)
empty = [] %what B will spit out an empty matrix if the pattern is not
%found in the file
if isequal(size(empty), size(B))
disp('No TWOPNT success found...may be a convergence problem')
error_message = 'No TWOPNT: SUCCESS found'
break
else %if the B matrix is not empty
disp('TWOPNT appears to have been successful! Conitnuing...')
endif
Paige Nardozzo
Paige Nardozzo el 8 de Dic. de 2015
I made this part of my code and ran it by itself and it worked fine. However when I went to input it into my overall code it gets to this section and it goes to the fileread and spits out A=>> and stops working. Is there a certain size limit? If so why did it work when I used it outside of the code but not in it? Thanks.

Respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by