Subject: A question about the chebfun() function From: Jeff Date: 1 Jul, 2012 03:04:24 Message: 1 of 5 Hi folks, I am using the chebfun function to find the eigenvalues and eigenfunctions of the following boundary value problem D^4 y=lambda*y, y''(0)=y'''(0)=y''(1)=y'''(1)=0, where D is the differential operator, lambda is the eigenvalue and the solution y is the corresponding eigenfunction. I used the following code in chebfun: L = chebop(@(x,u) diff(u,4), [0,1]); L.lbc = @(u) diff(u,2); L.lbc =@(u) diff(u,3); L.rbc = @(u) diff(u,2); L.rbc =@(u) diff(u,3); [V,D] = eigs(L,trunc); disp(diag(D)), toc HOWEVER, the below error was reported Error using eig Matrix must be square. Error in linop/eigs>bc_eig (line 288)     [V,D] = eig(full(Amat),full(Pmat)); Error in linop/eigs (line 94)     [V1,D1] = bc_eig(A,B,33,33,0,map,breaks); Error in chebop/eigs (line 57) [varargout{1:nargout}] = eigs(L,varargin{:}); Looks like I am on the right track but some nonsquare matrix caused that error. Sincerely appreciate your comments and suggestions. Thanks. Jeff
 Subject: A question about the chebfun() function From: Nasser M. Abbasi Date: 1 Jul, 2012 03:22:07 Message: 2 of 5 On 6/30/2012 10:04 PM, Jeff wrote: > Hi folks, > > I am using the chebfun function to find the eigenvalues and eigenfunctions >of the following boundary value problem > > D^4 y=lambda*y, y''(0)=y'''(0)=y''(1)=y'''(1)=0, > > where D is the differential operator, lambda is the eigenvalue and >the solution y is the corresponding eigenfunction. > > I used the following code in chebfun: > > L = chebop(@(x,u) diff(u,4), [0,1]); > L.lbc = @(u) diff(u,2); > L.lbc =@(u) diff(u,3); > L.rbc = @(u) diff(u,2); > L.rbc =@(u) diff(u,3); > [V,D] = eigs(L,trunc); > disp(diag(D)), toc > > HOWEVER, the below error was reported > > Error using eig > Matrix must be square. > what is trunc ? Please post complete code that can be run. non square matrix does not have eigenvalues by definition. " E = eig(X) is a vector containing the eigenvalues of a square      matrix X." note the words "square matrix" above. try eig(sqrt(L*L')) instead and see if this helps in your problem. --Nasser
 Subject: A question about the chebfun() function From: Jeff Date: 1 Jul, 2012 03:49:14 Message: 3 of 5 Thanks Nasser! The complete code is as follows: trunc=30; tic L = chebop(@(x,u) diff(u,4), [0,1]); L.lbc = @(u) diff(u,2); L.lbc =@(u) diff(u,3); L.rbc = @(u) diff(u,2); L.rbc =@(u) diff(u,3); [V,D] = eigs(L,trunc); disp(diag(D)), toc where trunc means how many eigenvalues I am asking for. In the above code, trunc=30 means I am asking chebfun() to find the first 30 eigenvalues. I agree with you that the above code produces some nonsquare matrix, which causes this error. But presumably the above code should present some square matrix, right? I have no idea what causes such nonsquare matrix. I tested the examples included in the chebfun document, which all produce square matrices. Thanks again for your kind help! Jeff "Nasser M. Abbasi" wrote in message ... > On 6/30/2012 10:04 PM, Jeff wrote: > > Hi folks, > > > > I am using the chebfun function to find the eigenvalues and eigenfunctions > >of the following boundary value problem > > > > D^4 y=lambda*y, y''(0)=y'''(0)=y''(1)=y'''(1)=0, > > > > where D is the differential operator, lambda is the eigenvalue and > >the solution y is the corresponding eigenfunction. > > > > I used the following code in chebfun: > > > > L = chebop(@(x,u) diff(u,4), [0,1]); > > L.lbc = @(u) diff(u,2); > > L.lbc =@(u) diff(u,3); > > L.rbc = @(u) diff(u,2); > > L.rbc =@(u) diff(u,3); > > [V,D] = eigs(L,trunc); > > disp(diag(D)), toc > > > > HOWEVER, the below error was reported > > > > Error using eig > > Matrix must be square. > > > > > what is trunc ? Please post complete code that can be run. > > non square matrix does not have eigenvalues by definition. > > " E = eig(X) is a vector containing the eigenvalues of a square > matrix X." > > note the words "square matrix" above. > > try eig(sqrt(L*L')) instead and see if this helps in your problem. > > --Nasser
 Subject: A question about the chebfun() function From: Nasser M. Abbasi Date: 1 Jul, 2012 04:04:12 Message: 4 of 5 On 6/30/2012 10:49 PM, Jeff wrote: > The complete code is as follows: > > trunc=30; > tic > L = chebop(@(x,u) diff(u,4), [0,1]); > L.lbc = @(u) diff(u,2); > L.lbc =@(u) diff(u,3); > L.rbc = @(u) diff(u,2); > L.rbc =@(u) diff(u,3); > [V,D] = eigs(L,trunc); > disp(diag(D)), toc > I do not use chebop. But I noticed you are using 'L.lbc=' on 2 lines. would this not overwrite the previous line? same with 'L.rbc=' ? Isn't this like writing x=4 x=5 ? Sorry, do not know use chebop. may be chebop does things differently here. Can't you extract the system matrix from the object L? Then you can use eig on A*A' and sqrt() the result. --Nasser
 Subject: A question about the chebfun() function From: Steven_Lord Date: 2 Jul, 2012 03:53:33 Message: 5 of 5 "Jeff " wrote in message news:jsoeno\$qjv\$1@newscl01ah.mathworks.com... > Hi folks, > > I am using the chebfun function to find the eigenvalues and eigenfunctions > of the following boundary value problem *snip* > HOWEVER, the below error was reported > Error using eig > Matrix must be square. > > Error in linop/eigs>bc_eig (line 288) > [V,D] = eig(full(Amat),full(Pmat)); You'll probably need to contact the Chebfun team for help determining the cause of this error. http://www.mathworks.com/matlabcentral/fileexchange/23972-chebfun -- Steve Lord slord@mathworks.com To contact Technical Support use the Contact Us link on http://www.mathworks.com

### Everyone's Tags:

Separated by commas
Ex.: root locus, bode

### What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.