フィルターのクリア

Subscript indices must be real positive error

2 ビュー (過去 30 日間)
Sandeep
Sandeep 2012 年 10 月 30 日
I am trying to run a code(part of which is mentioned below) where h,u and x values have been defined separately in the rest of the code.. When I try to run this code to plot piecewise function, it gives me the following error "Subscript indices must either be real positive integers or logicals.
Error in fem51uapprox (line 78) y(c:d-1)=r.^2; %u(2*m-1,1).*w1+u(2*m,1).*w2+u(2*m+1,1).*w3;"
Can anybody please tell me what I am supposed to do to get rid of the error?
r=0:0.01:1;
y=zeros(length(x));
for m=1:n
w1=(1./h).*(r-x(2.*m)).*((2./h).*(r-x(2.*m))-1);
w2=(1-(2./h).*(r-x(2.*m))).*((2./h).*(r-x(2.*m))+1);
w3=(1./h).*(r-x(2.*m)).*((2./h).*(r-x(2.*m))+1);
c=round((m-1)*h*100);
d=round(m*h*100);
y(c:d-1)=r.^2; %u(2*m-1,1).*w1+u(2*m,1).*w2+u(2*m+1,1).*w3;
end
a=0:0.001:1;
b=(1-((1+a).^(3./2)))./3;
plot(r,y,a,b,'b');
  1 件のコメント
Chris A
Chris A 2012 年 10 月 30 日
What is x?

サインインしてコメントする。

採用された回答

Matt J
Matt J 2012 年 10 月 30 日
編集済み: Matt J 2012 年 10 月 30 日
This line will give c=0 when m=1
c=round((m-1)*h*100);
you cannot use c=0 as an index into y, like you are currently doing in
y(c:d-1)=r.^2;
  1 件のコメント
Sandeep
Sandeep 2012 年 10 月 30 日
Thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by