Error when using writeif statement

1 vue (au cours des 30 derniers jours)
Jessica
Jessica le 16 Juil 2012
Hi, I am translating code from Fortran to Matlab with a converter and I get an error of "Unexpected MATLAB operator" in the following part:
for t = 1: ntime
for j = 1: nequation(t);
k = eqindex(t,j);
writef(fid_1,[repmat('%i',1,2),repmat('%16.8f',1,<)],t,k, beta(t,k,:), z(t,k,:), h(t,k,k));
writef(fid_1,[repmat('%i',1,2),repmat('%16.8f',1,<)],t,k,sdbeta(t,k,:),sdz(t,k,:),sdh(t,k,k));
writef(fid_1,['%0.15g \n']);
end;
writef(fid_1,['%0.15g \n']);
end;
Could someone please guide me as to what I am doing wrong?
Thanks,
Jessica
[EDITED, code formatted, Jan]
[EDITED 2, copied from Answers section, please care for a proper formatting]:
Thanks for your quick answers. I guess my main problem is that I am translating from Fortran with this converter and this is the output which I got, which I know makes no sense. Does anyone know Fortran and Matlab? In Fortran the code is:
do t = 1ntime do j = 1, nequation(t) k = eqindex(t,j) write(1,'(2I,<nx+nfac+1>f16.8)')t,k, beta(t,k,:), Z(t,k,:), H(t,k,k) write(1,'(2I,<nx+nfac+1>f16.8)')t,k,sdbeta(t,k,:),sdZ(t,k,:),sdH(t,k,k) write(1,*) end do write(1,*) end do close(1)
  2 commentaires
Jan
Jan le 16 Juil 2012
Modifié(e) : Jan le 16 Juil 2012
Please follow the "About MATLAB Answers" link to learn, how to format your code. It is hard to decide, if the line breaks are inserted by the forum layout or if they exist in the real source code also.
I find "writef" in the code, but "writeif" in the subject and the tags. I've modified the tag already.
Whenever you post an error message here, copy it completely. Especially the line, which causes the error, is very helpful.
Jan
Jan le 16 Juil 2012
Please, Jessica, learn how to use the "{} Code" button to format code. And please add information required to understand the question by editing the question, not by posting an answer. Thanks.

Connectez-vous pour commenter.

Réponses (2)

Sean de Wolski
Sean de Wolski le 16 Juil 2012
You are probably looking for fprintf or fwrite.
doc fprintf
doc fwrite

Jan
Jan le 16 Juil 2012
Modifié(e) : Jan le 16 Juil 2012
Beside that fact, that Matlab does not have a writef function, the expression:
repmat('%16.8f',1,<)
is not valid in Matlab. The "<" is obviously unexpected. What should happen here?
Did you ask the author of the converter already? What did he reply?

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by