Prev: using case statement on string inputs when number of case choices is unknown
Next: Biulding a diagonal matrix from submatrices
From: Sayanatn on 20 Mar 2010 03:12 Steve lord i need your help on the question i have and thanks matt,but i guess steve is handling my case and he will better understand my problem , i know you might be right but honestly i am a rookie and i didnt get it.sorry for toping the post.I need an explaination of the code and how will i write it ... "Matt Fig" <spamanon(a)yahoo.com> wrote in message <ho1gr0$sgd$1(a)fred.mathworks.com>... > Please don't top post. > > Since you have a polynomial, use roots. > > f = @(x) x.^3+2*x.^2+x+4*i; > rt = roots([1 2 1 4*i]) > f(rt) % Just to check
From: Walter Roberson on 20 Mar 2010 03:50 Sayanatn wrote: > Hey > I was trying to find complex zeroes by this code > % begin f.m > function y = f > fid = fopen('Newtons.dat','w');%%the file where the output will be > saved,fopen opens a file which is writeable%% > y = fzero(@subfunF,-2i); > fprintf(fid,'%15.12f \n',y); > fclose(fid) > > > function z = subfunF(x) > z=x.^2+2*x-4i; > %%z = x.^3-2*x -5; > % end f.m > > but its showing error as > > ??? Error using ==> fzero at 334 > Function value at starting guess must be finite and real. fzero is not designed to work with complex numbers. It has to choose a direction, left or right, to look for the next potential sign change, but complex numbers have four possible directions, greater or lesser on the real axis and greater or lesser on the imaginary axis. For your particular quadradic function, you would be better off using the exact method, that the roots are at (-b +/- sqrt(b^2 - 4*a*c))/(2*a) Likewise there are exact solutions for cubic functions; for x^3+b*x^2+c*x+d = 0, then the roots can be found as: P = -8*b^3 + 36*b*c - 108*d + 12*sqrt(12*b^3*d - 3*b^2*c^2 - 54*b*c*d + 12*c^3 + 81*d^2) t1 = -1/12*P^(1/3) + 3*(1/3*c - 1/9*b^2)/P^(1/3) - 1/3*b t2 = 1/2*I*3^(1/2)*(1/6*P^(1/3) + 6*(1/3*c - 1/9*b^2)/P^(1/3)) R1 = 1/6*P^(1/3)-6*(1/3*c-1/9*b^2)/P^(1/3)-1/3*b R2 = t1 + t2 R3 = t1 - t2 If for some reason you are required to use root-finding mechanism instead of the exact solution, then I suggest you use a minimizer on a function of two variables, with x = x1 + i*x2 . You will, however, have to think carefully about what quantity you will minimize in order to find the roots. abs(z) is tempting and always 0 or a positive real, but I am not convinced it will properly explore the full complex space.
From: ram on 1 Apr 2010 11:15
On Feb 24, 10:43 am, ram <ram280...(a)gmail.com> wrote: > Sir, sorry for the delayed reply, your work was really fascinating, > but now our lecturer is demanding that we aren't supposed to zoom the > image deliberately but that the area seleted is to be displayed with a > better resolution than the pixels around it. (1)How can we identify > "seed pixel", (2)For example, if we are supposed to work on a > finger's x-ray, we should give an arbitary color to the bone > (3)Detect the edge between the bone and soft tissue (4) Sharpen the > edge (5) Highlight in such a way that the bone tissue is the > foreground while the soft tissue remains the back ground sir, in mathworks, i got a link for region growing,"http:// www.mathworks.com/matlabcentral/fileexchange/19084-region-growing", but i don really know how to use it....i assigned I as the input image and program runs, gets the seeds, but the region doesnt seem to grow...can you help me with it....? |