how to read the complex numbers from ms excel?

6 Ansichten (letzte 30 Tage)
bsd
bsd am 3 Apr. 2012
Hai,
I have created a matrix in ms excel worksheet consisting of 5 rows and 5 columns. The matrix consists of complex numbers. I have to read this data from matlab. I used the command xlsread(), it is showing an empty matrix.
When I used the command xlsread() to read a matrix of real numbers, it worked.
But for my application I need to read the matrix of complex numbers.
Please suggest me a solution for this.
Looking for your reply.
BSD

Antworten (1)

Andreas Goser
Andreas Goser am 3 Apr. 2012
I assume you can get this working by importing the strings/character arrays into MATLAB using XLSREAD.
[num,txt,raw] = xlsread(filename)
As a next step, you and convert ther characters into a real and imaginary part. The code depends a bit on how your data is stored and imported though.
  3 Kommentare
Jonathan Sullivan
Jonathan Sullivan am 3 Apr. 2012
Did you try str2double?
a = {'3+2i','9-7i'}; % the data you read in, as a string
cellfun(@str2double,a)
Andreas Goser
Andreas Goser am 3 Apr. 2012
@Jonathan. That should work. @bsd: If not, giving data will allows us to help instead of guess.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Data Import from MATLAB finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by