1

我有一个包含亚马逊股票信息的 .csv 文件

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

我已将此文件加载到 Matlab 中,现在我想从该文件中读取数据以生成烛台图。这就是我所做的:

clear;
close all;

file = '/Users/Documents/MATLAB/Candlestick Chart/Amazon.csv';

candle (file(:,2), file(:,3),file(:,4),file(:,5), 'b', file(:,1))

 set(file(:,5), 'FaceColor', 'g')
 set(file(:,6), 'FaceColor', 'r')

运行 .m 文件时,我收到错误消息:

Error using dlmread (line 139)
Mismatch between file and format string.
Trouble reading number from file (row 1u, field 2u) ==>
/10/2013,361.08,4500014,362.62,365,358.65\n

Error in csvread (line 48)
    m=dlmread(filename, ',', r, c);

我知道该软件无法将日期转换为矢量,谁能帮我将日期转换为矢量并绘制蜡烛图。因此,在 X 访问中,我想显示日期并根据高、低、收盘价、开盘价绘制蜡烛图。

4

1 回答 1

0

您可以使用textscan

 fid = fopen(filename, 'r')
 C = textscan(fid, '%s%f%f%f%f%f', 'Headerlines', 2);
 fclose(fid)

C{2}然后在, C{3}, ... 中为您的绘图使用向量。

于 2013-11-14T20:52:21.967 回答