필터 지우기
필터 지우기

How to plot a candlestick chart

조회 수: 2 (최근 30일)
Dipesh Ramesh
Dipesh Ramesh 2013년 11월 18일
편집: Dipesh Ramesh 2013년 11월 21일
Hi,
I have a .csv file which contains stock information of Amazon e.g. date(30/10/2013), closePrice(361.08), volume(4500014), openPrice(362.62), highPrice(365), lowPrice(358.65). So there are about 2517 rows and 6 columns. First i want to read data from .csv file then plot a candlestick chart. So I have loaded my .csv file like this:
clear;
close all;
fid = fopen('Amazon.csv');
HDRS = textscan(fid,'%s %s %s %s %s %s',1, 'delimiter',',');
DATA = textscan(fid,'%s %f %f %f %f %f','delimiter',',');
fclose(fid);
outCell = cell(size(DATA{1},1), length(HDRS));
for i = 1:length(HDRS);
if isnumeric(DATA{i});
outCell(:,i) = num2cell(DATA{i});
else
outCell(:,i) = DATA{i};
end
end
candle (outCell{:,5}, outCell{:,6}, outCell{:,2}, outCell{:,4}, 'b', outCell{:,1});
but when running the file i get an error saying: Error using candle Too many input arguments. can someone help me i am sure matlab can read 2517X6 set of data to plot candlestick chart.
Thanks.
  댓글 수: 2
Walter Roberson
Walter Roberson 2013년 11월 18일
Why are you converting the numeric data into arrays of cells?
Dipesh Ramesh
Dipesh Ramesh 2013년 11월 19일
I am using an array so my program can read date, i was having a problem reading date from .csv file so i used an array.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2013년 11월 18일
MATLAB Coder (the product you indicated you are using) is not able to generate code for anything involving graphics: it is only suitable for generating C or C++ code for numeric routines. MATLAB Coder is also, if I recall, unable to generate code when cell arrays are used.
The problems you would observe would be different than the message you indicate you saw, as the code generation process would fail long before you were able to run a call to candle()
The simplest explanation is that you are not using the MATLAB Coder product.
  댓글 수: 3
Walter Roberson
Walter Roberson 2013년 11월 19일
Could you show a sample line from the file?
Dipesh Ramesh
Dipesh Ramesh 2013년 11월 20일
편집: Dipesh Ramesh 2013년 11월 21일
This is how my .csv file looks like, is this the sample you're looking for right?
date, closePrice, volume, openPrice, highPrice, lowPrice
===============================================================
30/10/2013 361.08 4500014 362.62 365 358.65
29/10/2013 362.7 2184755 358.96 362.89 356.29
28/10/2013 358.16 3602497 359.92 362.75 357.2
25/10/2013 363.39 12034820 358.6 368.4 352.62
24/10/2013 332.21 5699188 329.63 332.6499 326.75
I want to use these data to plot candlestick chart. The file have 2,500 rows and 6 columns

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by