필터 지우기
필터 지우기

I get Subscript indices must either be real positive integers or logicals.

조회 수: 2 (최근 30일)
if true
% N = 5000;
z = 2*randn(N,1);
x = (-9:0.25:9);
z1 = reshape(z,[10,500]);
y = mean(z1);
sdy = std(y);
E = exp(-(x.^2)./(2*(sdy^2)));
DeltaNy = (500./(sdy*sqrt(2*pi))).*E.*0.25;
plot(x,DeltaNy,'r-');
end
I have to use the formula for delta n which depends on the standard deviation of y but this values is too small and
I get Subscript indices must either be real positive integers or logicals. I don't know how to make the formula work, I need it to plot the normal distribution on a histogram. I have to use THAT formula and cant change it.

채택된 답변

Star Strider
Star Strider 2017년 11월 14일
The code you posted runs without error for me (in R2017b).
If it is throwing an error, please copy the complete error message (all the red text) from your Command Window and paste it to a Comment here.
  댓글 수: 5
Star Strider
Star Strider 2017년 11월 14일
My pleasure.
If my Answer helped you solve your problem, please Accept it!
Image Analyst
Image Analyst 2018년 9월 25일
When k is 1, then k-5 is -4. You can't have a negative 4 as the row number of a matrix.

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

추가 답변 (1개)

Image Analyst
Image Analyst 2017년 11월 14일

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by