Reading complex numbers from Excel

8 ビュー (過去 30 日間)
Abhinay Priyatham
Abhinay Priyatham 2019 年 11 月 7 日
回答済み: zhou qin 2022 年 9 月 30 日
Hi,
I have an excel sheet which has one column consisting of series of rows filled with complex numbers
eg:
-0.00340875447356980 - 0.143829744894360i
0.00826437724550120 - 0.0203601960662560i
0.0175899073253476 + 0.0143665796766208i
I have two variables 'a' and 'b'. I would like to import all the real values from the excel sheet to 'a' and all the imaginary values to 'b'.

採用された回答

Ankit
Ankit 2019 年 11 月 8 日
Step.1: Reading values from the excel sheet (see attachment).
[num,txt,raw] = xlsread('imag_real.xlsx')
Step.2: Apply a str2double to each cell of a cell array i.e. raw
data = cellfun(@str2double,raw)
Step.3: Storing real values to a and imaginary values to b
a = real(data);b = imag(data);

その他の回答 (1 件)

zhou qin
zhou qin 2022 年 9 月 30 日
excellent!

カテゴリ

Help Center および File ExchangeData Import from MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by