Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Subscript assignment Mismatch
Date: Fri, 9 Oct 2009 13:15:05 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 51
Message-ID: <hand0p$61p$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1255094105 6201 172.30.248.38 (9 Oct 2009 13:15:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 9 Oct 2009 13:15:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1608486
Xref: news.mathworks.com comp.soft-sys.matlab:576228


Hi there,

The code below worked fine until I chnaged the import of the text file.

The new file yield2 is esentially similar although slightly more columns.

However as the number of columns or indeed rows is not hard coded I don't see this should cause a problem?

How after changing the code to import yield2.txt the follwoing error message appeared

??? Subscripted assigment dimension mismatch?

Error in ==> curvefit at 11
xdata(i,:)=data(1:);

Please advise




%% datafitting parameters
clc
close all
clear screen
%data= dlmread('yield.txt','\t');
data= dlmread('yield2.txt','\t');
ydata=data(2:end,:);
%ydata=data(2,:);
k=size(ydata);
for i=1:k(1)
xdata(i,:)=data(1,:);
end
%x=eyes(2:end,:);oi 

%xdata=data(1,:);
xdata2=[2 5 10 30];
ydata2=[4.3 4.94 5.52 5.95];

xdata3=data(1,:);
ydata3=data(2,:);
%c0 = [1.0 2 3 4];% starting values
c0 = [1 1 1 1 1 1];

%c0 = [1.0 1 1];
lbn = []; % lower bound
ubn = []; % upper bound
options = optimset('LargeScale','on','MaxFunEvals',100000,'TolFun',1e-5,'MaxIter',10000 );


% datafitting
[cn,error]=lsqcurvefit(@PrimePerm,c0,xdata,ydata,lbn,ubn,options);