MATLAB で 複素数(complex) のデータを Excel ファイルに出力するにはどうすればよいですか?
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MathWorks Support Team
el 24 de Mayo de 2017
Respondida: MathWorks Support Team
el 15 de Jun. de 2017
xlswrite 関数で、複素数の行列を Excel ファイルとして保存しようと以下のコマンドを実行しました。
% create matrix of complex numbers
z = [2+3i 4+5i; 18+9i 1+17i];
% write the contents of the cell array to the Excel file
xlswrite('testfile',z)
しかし、作成された Excel ファイルを開きてみると、複素数の実部(real part)しか出力されていません。
実部と虚部のどちらも保存する方法を教えてください。
Respuesta aceptada
MathWorks Support Team
el 24 de Mayo de 2017
xlswrite 関数では、複素数のデータを出力することができません。
回避方法として、複素数の値を文字列として出力します。
以下の例では、複素数の数値データをセル配列に変換後、さらに文字列へ変換します。
z = [2+3i 4+5i; 18+9i 1+17i];
c = num2cell(z); % セル配列に変換
towrite = cellfun(@num2str , c, 'UniformOutput', false); % 各要素を文字列に変換
xlswrite('testfile_new',towrite) % Excel スプレッド形式として保存
0 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!