"Mohammad " <jaber2@uni.uiuc.edu> wrote in message <i3phfs$p51$1@fred.mathworks.com>...
> Dear reader,
>
> I have a sinusoidal function, v(x), which should be odd, since sin is an odd function, and x is an odd function, so sin(...)x should be odd.
> However when you plot it
>
> Star=[0.592606202481246,0.238596363969608,0.110220888524900,0.048828233710702,0.019375152829649,0.006571603729450,0.001814612417602,3.812550640549345e04,5.414560164816563e05,3.901808006180736e06];
> v = @(x) sin(pi*x(:)*(1:r))*Star.'+ax;
> fplot(v,[n o])
>
> it is not odd. Why?
> Thanks!
> Cordially, Mohammad
"Mohammad " <jaber2@uni.uiuc.edu> wrote in message <i3pj80$hea$1@fred.mathworks.com>...
> z = 1;
> n = .5;
> o = .5;
> a = 0;
> r = 10;
> b = 1;
> mat=zeros(r,r+1);
> for i= 1:r
> for j = 1:r
> mat(i,j) = sin(j*pi*(o(on)*(i1)/2/r));%(o(on)*(i1)/2/r)=x
> end
> for j = 1+r
> mat(i,j) = z*((o(on)*(i1)/2/r))^b;
> end
> end
> for j=2:r,
> for i=j:r,
> mat(i,:) = mat(i,:)  mat(j1,:)*mat(i,j1)/mat(j1,j1);
> end
> end
> Bat = rot90(mat,2);
> Hat=[Bat Bat(:,1)];
> Hat(:,1)=[];
> for j=2:r,
> for i=j:r,
> Hat(i,:) = Hat(i,:)  Hat(j1,:)*Hat(i,j1)/Hat(j1,j1);
> end
> end
> Fat = rot90(Hat,2);
> Rat=[Fat Fat(:,1)];
> Rat(:,1)=[];
> Star=zeros(1,r);
> for i = 1:r
> Star(1,i)=Rat(i,end)/Rat(i,i);
> end
> v = @(x) sin(pi*x(:)*(1:r))*Star.'+ax^b;
> fplot(v,[n o])
> fid = fopen('hope.txt', 'w');
> number3 = a;
> fprintf(fid,['A0 is ' num2str(number3)]);
> for i = 1:r
> number = Star(1,i);
> number2 = i;
> fprintf(fid,['\nA' num2str(number2) ' is ' num2str(number)]);
> end
> fclose(fid);
> type hope.txt
         
Hello Mohammad. I think I know what went wrong with fplot. It apparently started from the 'n' end at x = .5 and initially spaced x points close together. However during the long stretch in the middle where your v values are very nearly a constant zero, it got overconfident and began to space the x values farther and farther apart until near the other 'o' end at x = +.5 the last five x values out of a total of 121 it tried were:
x = .208
x = .144
x = .016
x = +.240
x = +.500
This huge gap misses all the interesting variation in v at the right end and accounts for why the plot is so terribly inaccurate. It is the kind of behavior that functions like quad do in their calls to integrand functions which remain nearly constant for too long an interval.
My advice would be not to use fplot at all on the kind of stuff you're working with. Just use the straight 'plot' function. That way you know exactly what spacing is being used in the plotting. It is not being left up to some algorithm which is trying to be too smart for its own good.
Roger Stafford
