I should clarify, that I'm not necessarily trying to write an output file, I'm just trying to display the variable, even if it's just in the Command Window.
Display output in FORTRAN format ?
3 次查看(过去 30 天)
显示 更早的评论
How do I display the numerical contents of an array so that rather than looking like:
A=
5.43297486350203e-005 + 2.66188191742774e-006i
4.93260233930857e-006 + 9.43375107613982e-005i
3.40870376238982e-004 - 5.64562919171371e-003i
it gives something that can be copied and pasted into a FORTRAN code ?
回答(1 个)
Walter Roberson
2012-6-16
fprintf(fid, '(%f,%f)\n', [real(A(:)), imag(A(:))].' )
2 个评论
Walter Roberson
2012-6-16
Nope. But if you want you can create
function s = FortranComplex(V)
s = sprintf( '(%f,%f)', real(V(1)), imag(V(1)) );
and then use the output string in whatever context you want.
If you have the symbolic toolbox, you could try
http://www.mathworks.com/help/toolbox/symbolic/fortran.html
fortran(A) but you might have use fortran(sym(A))
另请参阅
类别
在 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!