0

I have a matrix where the first column contains dates and the first row contains maturities which are alpha/numeric (e.g. 16year).

The rest of the cells contain the rates for each day, which are double precision numbers.

Now I believe xlsread() can only handle numeric data so I think I will need something else or a combination of functions?

I would like to be able to read the table from excel into MATLAB as one array or perhaps a struct() so that I can keep all the data together.

The other problem is that some of the rates are given as '#N/A'. I want the cells where these values are stored to be kept but would like to change the value to blank=" ". What is the best way to do this? Can it be done as part of the input process?

1 Answer 1

1

Well, from looking at matlab reference for xlsread you can use the format

[num,txt,raw] = xlsread(FILENAME)

and then you will have in num a matrix of your data, in txt the unreadable data, i.e. your text headers, and in raw you will have all of your data unprocessed. (including the text headers).

So I guess you could use the raw array, or a combination of the num and txt.

For your other problem, if your rates are 'pulled' from some other source, you can use

=IFERROR(RATE DATA,"")

and then there will be a blank instead of the error code #N\A.

Another solution (only for Windows) would be to use xlsread() format which allows running a function on your imported data,

[num,txt,raw,custom] = xlsread(filename,sheet,xlRange,'',functionHandler)

and let the function replace the NaN values with blank spots. (and you will have your output in the custom array)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.