Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How to create a submatrix based on an existing matrix?

Subject: How to create a submatrix based on an existing matrix?

From: Laurentiu Galan

Date: 3 Dec, 2010 18:02:07

Message: 1 of 2

1.) I have a series of prices for an instrument:
say:
               (Closing Prices)
Date1...........35.6
Date2...........35.75
Date3...........34.23
Date4...........36.7
Date5...........33.4
.
.
.
Date_n..........56.7

How do I create a matrix that calculates returns in increments of 2? and places
it in the corresponding cell next to the ending price?
I want a new nx1 matrix that looks something like this:
0 (because I don't have the 2 previous days closing prices)
0 (because I don't have the 2 previous days closing prices)
(34.23-35.6)/35.6
(36.7-35.75)/35.75
(33.4-34.23)/34.23
.
.
.
(Closing_Price_on_Date_N-Closing_Price_on_Date_(N-2))/Closing_Price_on_Date_(N-2))

Thank you so much guys,

It's an if then/loop statement that I don't know how to do...


 

Subject: How to create a submatrix based on an existing matrix?

From: Matt Fig

Date: 3 Dec, 2010 18:31:08

Message: 2 of 2

What format is your data? I hope you do not have a bunch of different variables with names like: date_n

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us