Plotting Moving Average of NASDAQ

조회 수: 7 (최근 30일)
3nore
3nore 2013년 2월 11일
Hi, I want to plot a Moving Average and a Histogram chart of Nasdaq prices. I created a function called fmean to compute the average of an array's components. Can you show me what I am doing wrong? ..........................................................................
nasdaq = [];
sma = [];
x = 0;
n = 1;
m = 30; %moving avg.
l = length(nasdaq(:,5))
for i = (n+x):(m+x)
sma = fmean(i)
end
x = x+1;
if x = l-m
ts1 = timeseries(sma);
ts1.Name = 'SMA';
ts1.TimeInfo.Units = 'days';
ts1.TimeInfo.StartDate = nasdaq(1:1)
ts1.TimeInfo.Format = 'dd mm yy'
ts2 = timeseries(stock[]);
ts2.Name = 'SMA';
ts2.TimeInfo.Units = 'SMA';
ts2.TimeInfo.StartDate = nasdaq(1:1)
ts2.TimeInfo.Format = 'dd mm yy'
plot(ts1,ts2) grid on
hist(sma)
hist(nasdaq)
end
end

답변 (1개)

Image Analyst
Image Analyst 2013년 2월 11일
You say: "I created a function called fmean to compute the average of an array's components". Then you call it like this:
sma = fmean(i);
can you tell me how fmean is supposed to compute the average of anything from any array when you're not passing it any array? You're just passing an index. Are you passing the array through some other means such as global or getappdata()?
  댓글 수: 1
3nore
3nore 2013년 2월 12일
thank you for trying to answerthe question.I thought I passed the array 'I' into fmean. And 'I' is the array described just above where you first saw fmean used.
Maybe you could write your code and show me how its done.

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

카테고리

Help CenterFile Exchange에서 ThingSpeak에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by