Thread Subject: Fitting Superquadrics

Subject: Fitting Superquadrics

From: Mayur Mudigonda

Date: 18 Jun, 2008 19:08:02

Message: 1 of 1

Hello,

I am trying to fit superquadrics[A.H.Barr] to some data that
I have and Im facing some difficulties.

My objective function is defined as:

function f= super_fitting(a,data)
x=data(1,:);
y=data(2,:);
    term1=((x/a(1)).^(2/a(5)));
    term2=((y/a(2)).^(2/a(5)));
f= a(3)* ((1- ((term1+term2).^(a(5)/a(4))) .^ (a(4)/2))
 
% f = (term1+term2).*a(3)+ a(4) ;
% f= ((data(1,:).^2)/(a(1)^2)) + ((data(2,:).^2)/(a(2)^2));
% f= data(:,1).^2 .*a(1) + data(:,2).^2 .*a(2);.^( a(5)/a(4
end

I have generated data (parabolic) using a script like so:

function [x,y,z,xx,yy,zz] = parabolic_surface_generate(a,b,n)

if nargin ==0
    %Generate around (0,0,0) about n*2 points
    %We assume a and b to be 1
    n=20; a=1;b=1;
end
    x= [-n:2:0; 0:2:n];
    y= [-n:2:0; 0:2:n];
    
    %computing y
    z= ((x.^2)/a^2) + ((y.^2)/b^2);
%For Plotting
     xx=x;yy=y;zz=z;
%Data
 x=[x(1:end,1);x(1:end,2)];
 y=[y(1:end,1);y(1:end,2)];
 z=[z(1:end,1);z(1:end,2)];
end

Once, I've generated the data, I fit it by using a statement
like so,
data=[x;y];
[a,res]=lsqcurvefit(@super_fitting,a0,data,z)

So, I've gotten the following errors at different times

1) I get complex values of the co-efficients
2) I get an error like so,

??? Error using ==> qr
Complex sparse QR is not yet available.

Error in ==> aprecon at 57
   RPCMTX = qr(TM(:,p));

Error in ==> trdog at 47
         [R,permR] = feval(pcmtx,H,pcoptions,DM,DG,varargin{:});

Error in ==> snls at 345
      [sx,snod,qp,posdef,pcgit,Z] = trdog(x,g,A,D,delta,dv,...

Error in ==> lsqncommon at 231
    [x,FVAL,LAMBDA,JACOB,EXITFLAG,OUTPUT,msg]=...

Error in ==> lsqcurvefit at 186
[x,Resnorm,FVAL,EXITFLAG,OUTPUT,LAMBDA,JACOB] = ...


I have got co-efficients of a superquadric for a fit at
other times.

Potential issues:
I save my scripts on a network drive and am using Matlab
using a common Egr license.

When I get this error, I usually go back to fitting a sphere
and then up my way to a Super quadric and sometimes it works
(???)

I am lost here and any help would be much appreciated. I
have spent a lot of time poring through the matlab archives
and am hoping John or somebody could help me with this.

Thanks,
M

Tags for this Thread

Everyone's Tags:

Add a New Tag:

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.

Tag Activity for This Thread
Tag Applied By Date/Time
sparse qr complex Mayur Mudigonda 18 Jun, 2008 15:10:21
superquadrics Mayur Mudigonda 18 Jun, 2008 15:10:21
curve fitting Mayur Mudigonda 18 Jun, 2008 15:10:21
lsqcurvefit Mayur Mudigonda 18 Jun, 2008 15:10:21
rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com