hello everyone please can someone help me with stock price prediction. That is I wrote this code and from the I vector , I want a code that will remove indexes from the I vector more than 60 seconds. Thanks

조회 수: 2 (최근 30일)
LSE_matrix =log(nstock_val); %log of the data
I=1:(size(LSE_matrix,1)-1); % selecting the indices of all prices but the last time when stock was opened
dLSE_col1 = LSE_matrix(I+1,1) - LSE_matrix(I,1);% log difference
  댓글 수: 5
Afua Amoako Dadey
Afua Amoako Dadey 2020년 7월 6일
Atttached is of picture the corresponding times. So say we consider 498 and 498. its more than 60 sec. how do i write a code to remove such an index. Thanks for the help.
jonas
jonas 2020년 7월 6일
Dont you think it would be easier if you upload a sample of the data?

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

채택된 답변

jonas
jonas 2020년 7월 6일
편집: jonas 2020년 7월 6일
You can adapt this to your needs
A = readtable('LSE1.csv')
t = datetime(A{:,1},'inputformat','dd.MM.yyyy HH:mm:ss.SSS')
data = A{:,2:end};
id = [false;diff(t)>seconds(60)];
data(id,:) = [];
t(id) = [];
If the period between t(n) and t(n+1) is longer than 60s, then the data recorded at t(n+1) is deleted.
  댓글 수: 6
jonas
jonas 2020년 7월 9일
편집: jonas 2020년 7월 9일
I don't understand exactly what the problem is, but I'm not a big fan of how you structure the data. I would put all my .csv files in a separate folder and read them as follows:
addpath('C:\files\') % change this to the correct path
files = dir('C:\files\*.csv'); % again..
for i = 1:numel(files)
opts = detectImportOptions(files(i).name);
opts.VariableTypes{1} = 'datetime';
opts = setvaropts(opts,'GmtTime','inputformat','dd.MM.yyyy HH:mm:ss.SSS');
A{i} = readtimetable(files(i).name,opts);
end
You will end up with 5 tables stored in cell array A. You can then append them to a single table or loop over each tables, no need to work with "Var1, Var2, Var3..."

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

추가 답변 (1개)

Afua Amoako Dadey
Afua Amoako Dadey 2020년 7월 6일
Please find attached

카테고리

Help CenterFile Exchange에서 Chart Financial Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by