• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1151
  • Last Modified:

How to plot graph of financial data with matlab?

Hi,
I am new with Matlab and need some help:
I have financial data that I can produce from another application to a text file.
the  text file structure will be like: (I can change it)

1,1.4524
2,1.4520
3,1.4530
4,1.4520
5,0
6,0
7,0
.
.

The left column (1,2,3,4,..) represents the time in minutes.
The right collumn represents the values that I want to see in the Y axis.

I iuse the File->Import Data to import  the data text file into Matlab.

1) How to write the command for plotting the graph?
2) In case that I want to have a graph of 10 min intervals instead of 1 minute intervals, how to do it from Matlab?

3) When there is no data (e.g. weekend) the right column gets value 0, What is the recommended solution for showing 0 data on the graph(but only as indicator, not spending too much graph space)?
4) How to scale the Y axis to show the correct values? (In this example from 0.9 to 2)
Thanks!
0
star90
Asked:
star90
1 Solution
 
yuk99Commented:
See the code below with comments (after %). In case of missing data you can write NaN (not-a-number) to the data file. Or convert 0s to NaN. There will be a gap on the plot.
%% Read the data from comma-delimited file
data = csvread('filename.txt');
%% Convert 0s to NaNs
data(data(:,2)==0,2)=NaN;
%% plot 2nd column vs. 1st
plot(data(:,1),data(:,2))
%% plot symbols without lines (see PLOT help for details)
plot(data(:,1),data(:,2),'r*')
%% plot with 10 min interval
plot(data(1:10:end,1),data(1:10:end,2))
%% Scale the Y axis
ylim([0.9 2])

Open in new window

0
 
star90Author Commented:
Thanks a lot.
Its working well !
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now