MATLAB Newsgroup

%% datafitting parameters

tic;

clc

close all

clear screen

data= dlmread('yield.txt','\t');

%data= dlmread('yield2.txt','\t');

ydata=data(2,:);

xdata=data(1,:);

%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];

%ydata2=[4.21 4.6725 5.2375 5.715];

xdata3=data(1,:);

ydata3=data(2,:);

%c0 = [1.0 2 3 4];% starting values

%c0 = [1.0 1 1];

%lbn = [-Inf -Inf -Inf -Inf -Inf -Inf]; % lower bound

%ubn = [Inf Inf Inf Inf Inf Inf]; % upper bound

options = optimset('LargeScale','on','MaxFunEvals',10000000,'TolFun',1e-9,'MaxIter',1000000);

z=0;

for (i=0.01:5.01:25.1)

for (j=0.01:5.01:25.1)

for (k=0.01:1.01:5.01)

tic;

c0 = [5.95 1 1 1 i j 0.9 k 0.9 ];

%c0 = [1 1 1 1 1 0.1+i 0.9 0.9 0.9];

%c0 = [4.103594575 21.37812216 -66.97062464 0.079861881 1.81897068 -6.547214299 15.17678637 1.675525953 11.67454445];

%lbn = [-Inf -Inf -Inf -Inf i-0.00000001 j-0.00000001 -Inf k-0.00000001 -Inf]; % lower bound

%ubn = [Inf Inf Inf Inf i+0.00000001 j+0.00000001 Inf k+0.00000001 Inf];

lbn=[];

ubn=[];

z=z+1

% datafitting

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

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

%[cn,error]=lsqcurvefit(@PrimePerm3,c0,xdata3,ydata3,lbn,ubn,options);

[cn,error,diff,exitf,optdata]=lsqcurvefit(@PrimePerm3,c0,xdata,ydata,lbn,ubn,options);

y=PW(xdata2,ydata2,cn(5),cn(6),cn(7),cn(8),cn(9));

params = y';

%params= [cn(1) cn(2) cn(3) cn(4) ];

params=[params cn(5) cn(6) cn(7) cn(8) cn(9)];

y=CRM(xdata3,params);

error2=(y-ydata3).^2;

error2 = sum(error2);

%Res(1,:) = [cn params error error2];

toc

Res(z,:) = [c0 cn params y error error2 toc];

Res2(z,:) =[exitf optdata.firstorderopt optdata.iterations optdata.funcCount optdata.cgiterations optdata.algorithm optdata.message ];

end

end

end

optim=find(Res(:,43)==min(Res(:,43)));

toc;

Res2 =

large-scale: trust-region reflective NewtonOptimization terminated: norm of the current step is less

than OPTIONS.TolX.

Why do I not get the full set of information back?

I want to be able to transfer the data in Res 2 to excel, for all the other variables I just do this by cutting i n pasting from the variable editor. However, when I try to look at Res2 in variable editor it just shows a black cell? Can you tell me how to export this data to excel?

"Hugh " <h_a_patience@hotmail.com> wrote in message

news:hdejdr$gi5$1@fred.mathworks.com...

*snip*

> Res(z,:) = [c0 cn params y error error2 toc];

> Res2(z,:) =[exitf optdata.firstorderopt optdata.iterations

> optdata.funcCount optdata.cgiterations optdata.algorithm

> optdata.message ];

> end

> end

> end

>

> optim=find(Res(:,43)==min(Res(:,43)));

>

> toc;

>

> Res2 =

> large-scale: trust-region reflective NewtonOptimization terminated:

> norm of the current step is less

> than OPTIONS.TolX.

>

> Why do I not get the full set of information back?

You do ... just not in the form you expected.

> I want to be able to transfer the data in Res 2 to excel, for all the

> other variables I just do this by cutting i n pasting from the variable

> editor. However, when I try to look at Res2 in variable editor it just

> shows a black cell? Can you tell me how to export this data to excel?

When you concatenate together character data and non-character data using

[], as you did when you constructed Res2, the non-character data is

converted into characters.

newstring = ['This string contains the character A: ' 65] % 65 is the ASCII

value for 'A'

So all but the last two components of the optdata structure that you

combined are converted into characters, and since most of them should be

small the characters into which they were converted are ASCII control

characters:

http://en.wikipedia.org/wiki/ASCII#ASCII_control_characters

You probably want to create Res2 as a cell array, not a vector.

newcellstr = {'This cell array contains the number 65: ', 65}

--

Steve Lord

slord@mathworks.com

comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

"Steven Lord" <slord@mathworks.com> wrote in message <hdem2h$68c$1@fred.mathworks.com>...

>

> "Hugh " <h_a_patience@hotmail.com> wrote in message

> news:hdejdr$gi5$1@fred.mathworks.com...

>

> *snip*

>

> > Res(z,:) = [c0 cn params y error error2 toc];

> > Res2(z,:) =[exitf optdata.firstorderopt optdata.iterations

> > optdata.funcCount optdata.cgiterations optdata.algorithm

> > optdata.message ];

> > end

> > end

> > end

> >

> > optim=find(Res(:,43)==min(Res(:,43)));

> >

> > toc;

> >

> > Res2 =

> > large-scale: trust-region reflective NewtonOptimization terminated:

> > norm of the current step is less

> > than OPTIONS.TolX.

> >

> > Why do I not get the full set of information back?

>

> You do ... just not in the form you expected.

>

> > I want to be able to transfer the data in Res 2 to excel, for all the

> > other variables I just do this by cutting i n pasting from the variable

> > editor. However, when I try to look at Res2 in variable editor it just

> > shows a black cell? Can you tell me how to export this data to excel?

>

> When you concatenate together character data and non-character data using

> [], as you did when you constructed Res2, the non-character data is

> converted into characters.

>

> newstring = ['This string contains the character A: ' 65] % 65 is the ASCII

> value for 'A'

>

> So all but the last two components of the optdata structure that you

> combined are converted into characters, and since most of them should be

> small the characters into which they were converted are ASCII control

> characters:

>

> http://en.wikipedia.org/wiki/ASCII#ASCII_control_characters

>

> You probably want to create Res2 as a cell array, not a vector.

>

> newcellstr = {'This cell array contains the number 65: ', 65}

>

> --

> Steve Lord

> slord@mathworks.com

> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

>

Thank you so so much!!!

I've amended the code but hit another glitch

%% datafitting parameters

tic;

clc

close all

clear screen

data= dlmread('yield.txt','\t');

%data= dlmread('yield2.txt','\t');

ydata=data(2,:);

xdata=data(1,:);

%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];

%ydata2=[4.21 4.6725 5.2375 5.715];

xdata3=data(1,:);

ydata3=data(2,:);

%c0 = [1.0 2 3 4];% starting values

%c0 = [1.0 1 1];

%lbn = [-Inf -Inf -Inf -Inf -Inf -Inf]; % lower bound

%ubn = [Inf Inf Inf Inf Inf Inf]; % upper bound

options = optimset('LargeScale','on','MaxFunEvals',10000000,'TolFun',1e-9,'MaxIter',1000000);

z=0;

for (i=0.01:5.01:25.1)

for (j=0.01:5.01:25.1)

for (k=0.01:1.01:5.01)

tic;

c0 = [5.95 1 1 1 i j 0.9 k 0.9 ];

%c0 = [1 1 1 1 1 0.1+i 0.9 0.9 0.9];

%c0 = [4.103594575 21.37812216 -66.97062464 0.079861881 1.81897068 -6.547214299 15.17678637 1.675525953 11.67454445];

%lbn = [-Inf -Inf -Inf -Inf i-0.00000001 j-0.00000001 -Inf k-0.00000001 -Inf]; % lower bound

%ubn = [Inf Inf Inf Inf i+0.00000001 j+0.00000001 Inf k+0.00000001 Inf];

lbn=[];

ubn=[];

z=z+1

% datafitting

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

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

%[cn,error]=lsqcurvefit(@PrimePerm3,c0,xdata3,ydata3,lbn,ubn,options);

[cn,error,diff,exitf,optdata]=lsqcurvefit(@PrimePerm3,c0,xdata,ydata,lbn,ubn,options);

y=PW(xdata2,ydata2,cn(5),cn(6),cn(7),cn(8),cn(9));

params = y';

%params= [cn(1) cn(2) cn(3) cn(4) ];

params=[params cn(5) cn(6) cn(7) cn(8) cn(9)];

y=CRM(xdata3,params);

error2=(y-ydata3).^2;

error2 = sum(error2);

%Res(1,:) = [cn params error error2];

toc

Res(1,:) = [c0 cn params y error error2 toc];

Res2(1,:) = [exitf];

Res3(1,:) = [optdata.firstorderopt];

Res4(1,:) = [optdata.iterations];

Res5(1,:) = [optdata.funcCount];

Res6(1,:) = [optdata.cgiterations];

Res7(z,:) = [optdata.algorithm];

Res8(z,:) = [optdata.message];

Res9(z,:) = [Res Res2 Res3 Res4 Res5 Res6];

end

end

end

optim=find(Res(:,43)==min(Res(:,43)));

toc;

??? Subscripted assignment dimension mismatch.

Error in ==> CurveGroups at 84

Res8(z,:) = [optdata.message];

The complier thinks its a subscript problem but I can't understand how. It happened on loop 34 the only difference between this and eaelier loops is that optdata.message is returning a different error message

"Hugh " <h_a_patience@hotmail.com> wrote in message

news:hdenkv$fuv$1@fred.mathworks.com...

> "Steven Lord" <slord@mathworks.com> wrote in message

> <hdem2h$68c$1@fred.mathworks.com>...

>>

>> "Hugh " <h_a_patience@hotmail.com> wrote in message

>> news:hdejdr$gi5$1@fred.mathworks.com...

*snip*

> Thank you so so much!!!

*snip*

> Res(1,:) = [c0 cn params y error error2 toc];

> Res2(1,:) = [exitf];

> Res3(1,:) = [optdata.firstorderopt];

> Res4(1,:) = [optdata.iterations];

> Res5(1,:) = [optdata.funcCount];

> Res6(1,:) = [optdata.cgiterations];

Are you sure these shouldn't be Res(z, :), Res2(z, :), etc. like your Res7,

Res8, and Res9 assignment statements below? Although actually, take a look

below for a better solution.

> Res7(z,:) = [optdata.algorithm];

> Res8(z,:) = [optdata.message];

> Res9(z,:) = [Res Res2 Res3 Res4 Res5 Res6];

>

> end

> end

> end

>

> optim=find(Res(:,43)==min(Res(:,43)));

>

> toc;

>

> ??? Subscripted assignment dimension mismatch.

> Error in ==> CurveGroups at 84

> Res8(z,:) = [optdata.message];

>

> The complier thinks its a subscript problem but I can't understand how. It

> happened on loop 34 the only difference between this and eaelier loops is

> that optdata.message is returning a different error message

All the rows of a matrix must have the same number of columns. As you've

written it, if at one iteration the message is shorter than a previous

message, it will try to fill in the zth row with a string containing fewer

columns than Res8 has.

As I said before, use cell arrays, something like:

Res = cell(numberOfIterations, 9);

for z = 1:numberOfIterations

% Perform your calls

Res{z, 1} = [c0 cn params ...

Res{z, 2} = exitf;

Res{z, 3} = ...

...

Res{z, 8} = optdata.message;

...

end

--

Steve Lord

slord@mathworks.com

comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

"Steven Lord" <slord@mathworks.com> wrote in message <hdevvf$pmg$1@fred.mathworks.com>...

>

> "Hugh " <h_a_patience@hotmail.com> wrote in message

> news:hdenkv$fuv$1@fred.mathworks.com...

> > "Steven Lord" <slord@mathworks.com> wrote in message

> > <hdem2h$68c$1@fred.mathworks.com>...

> >>

> >> "Hugh " <h_a_patience@hotmail.com> wrote in message

> >> news:hdejdr$gi5$1@fred.mathworks.com...

>

> *snip*

>

> > Thank you so so much!!!

>

> *snip*

>

> > Res(1,:) = [c0 cn params y error error2 toc];

> > Res2(1,:) = [exitf];

> > Res3(1,:) = [optdata.firstorderopt];

> > Res4(1,:) = [optdata.iterations];

> > Res5(1,:) = [optdata.funcCount];

> > Res6(1,:) = [optdata.cgiterations];

>

> Are you sure these shouldn't be Res(z, :), Res2(z, :), etc. like your Res7,

> Res8, and Res9 assignment statements below? Although actually, take a look

> below for a better solution.

>

> > Res7(z,:) = [optdata.algorithm];

> > Res8(z,:) = [optdata.message];

> > Res9(z,:) = [Res Res2 Res3 Res4 Res5 Res6];

> >

> > end

> > end

> > end

> >

> > optim=find(Res(:,43)==min(Res(:,43)));

> >

> > toc;

> >

> > ??? Subscripted assignment dimension mismatch.

> > Error in ==> CurveGroups at 84

> > Res8(z,:) = [optdata.message];

> >

> > The complier thinks its a subscript problem but I can't understand how. It

> > happened on loop 34 the only difference between this and eaelier loops is

> > that optdata.message is returning a different error message

>

> All the rows of a matrix must have the same number of columns. As you've

> written it, if at one iteration the message is shorter than a previous

> message, it will try to fill in the zth row with a string containing fewer

> columns than Res8 has.

>

> As I said before, use cell arrays, something like:

>

> Res = cell(numberOfIterations, 9);

> for z = 1:numberOfIterations

> % Perform your calls

> Res{z, 1} = [c0 cn params ...

> Res{z, 2} = exitf;

> Res{z, 3} = ...

> ...

> Res{z, 8} = optdata.message;

> ...

> end

>

> --

> Steve Lord

> slord@mathworks.com

> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

>

Hi Steve,

I made the amendments re your earlier post, however, all that the cells in Res return is "[]". What as I doing wrong? (the altered code is shown below)

%% datafitting parameters

tic;

clc

close all

clear screen

%data= dlmread('yield.txt','\t');

data= dlmread('yield2.txt','\t');

ydata=data(2,:);

xdata=data(1,:);

%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];

ydata2=[4.21 4.6725 5.2375 5.715];

xdata3=data(1,:);

ydata3=data(2,:);

%c0 = [1.0 2 3 4];% starting values

%c0 = [1.0 1 1];

%lbn = [-Inf -Inf -Inf -Inf -Inf -Inf]; % lower bound

%ubn = [Inf Inf Inf Inf Inf Inf]; % upper bound

options = optimset('LargeScale','off','MaxFunEvals',1000000,'TolFun',1e-5,'MaxIter',1000000);

z=0;

for (i=0.01:5.01:25.1)

for (j=0.01:5.01:25.1)

for (k=0.01:1.01:5.01)

tic;

c0 = [5.95 1 1 1 i j 0.9 k 0.9 ];

%c0 = [1 1 1 1 1 0.1+i 0.9 0.9 0.9];

%c0 = [4.103594575 21.37812216 -66.97062464 0.079861881 1.81897068 -6.547214299 15.17678637 1.675525953 11.67454445];

%lbn = [-Inf -Inf -Inf -Inf i-0.00000001 j-0.00000001 -Inf k-0.00000001 -Inf]; % lower bound

%ubn = [Inf Inf Inf Inf i+0.00000001 j+0.00000001 Inf k+0.00000001 Inf];

lbn=[];

ubn=[];

z=z+1

% datafitting

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

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

%[cn,error]=lsqcurvefit(@PrimePerm3,c0,xdata3,ydata3,lbn,ubn,options);

[cn,error,diff,exitf,optdata]=lsqcurvefit(@PrimePerm3,c0,xdata,ydata,lbn,ubn,options);

y=PW(xdata2,ydata2,cn(5),cn(6),cn(7),cn(8),cn(9));

params = y';

%params= [cn(1) cn(2) cn(3) cn(4) ];

params=[params cn(5) cn(6) cn(7) cn(8) cn(9)];

y=CRM(xdata3,params);

error2=(y-ydata3).^2;

error2 = sum(error2);

%Res(1,:) = [cn params error error2];

toc

Res=cell(180,9);

% Res(1,:) = [c0 cn params y error error2 toc];

% Res2(1,:) = [exitf];

% Res3(1,:) = [optdata.firstorderopt];

% Res4(1,:) = [optdata.iterations];

% Res5(1,:) = [optdata.funcCount];

% Res6(1,:) = [optdata.cgiterations];

% Res7(z,:) = [optdata.algorithm];

% Res8(z,:) = [optdata.message];

% Res9(z,:) = [Res Res2 Res3 Res4 Res5 Res6];

Inpts(z,:) = [c0 cn params y error error2 toc];

Res{z,1} = exitf;

Res{z,2} = optdata.firstorderopt;

Res{z,3} = optdata.iterations;

Res{z,4} = optdata.funcCount;

%Res6(1,:) = [optdata.cgiterations];

Res{z,5} = optdata.stepsize;

Res{z,6} = optdata.algorithm;

Res{z,7} = optdata.message;

%Res9(z,:) = [Res Res2 Res3 Res4 Res5 Res6];

end

end

end

%optim=find(Res{:,43}==min(Res{:,43}));

toc;

You can think of your watch list as threads that you have bookmarked.

You can add tags, authors, threads, and even search results to your watch list. This way you can easily keep track of topics that you're interested in. To view your watch list, click on the "My Newsreader" link.

To add items to your watch list, click the "add to watch list" link at the bottom of any page.

To add search criteria to your watch list, search for the desired term in the search box. Click on the "Add this search to my watch list" link on the search results page.

You can also add a tag to your watch list by searching for the tag with the directive "tag:tag_name" where tag_name is the name of the tag you would like to watch.

To add an author to your watch list, go to the author's profile page and click on the "Add this author to my watch list" link at the top of the page. You can also add an author to your watch list by going to a thread that the author has posted to and clicking on the "Add this author to my watch list" link. You will be notified whenever the author makes a post.

To add a thread to your watch list, go to the thread page and click the "Add this thread to my watch list" link at the top of the page.

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.

Got questions?

Get answers.

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn moreDiscover what MATLAB ^{®} can do for your career.

Opportunities for recent engineering grads.

Apply TodayThe newsgroups are a worldwide forum that is open to everyone. Newsgroups are used to discuss a huge range of topics, make announcements, and trade files.

Discussions are threaded, or grouped in a way that allows you to read a posted message and all of its replies in chronological order. This makes it easy to follow the thread of the conversation, and to see what’s already been said before you post your own reply or make a new posting.

Newsgroup content is distributed by servers hosted by various organizations on the Internet. Messages are exchanged and managed using open-standard protocols. No single entity “owns” the newsgroups.

There are thousands of newsgroups, each addressing a single topic or area of interest. The MATLAB Central Newsreader posts and displays messages in the comp.soft-sys.matlab newsgroup.

**MATLAB Central**

You can use the integrated newsreader at the MATLAB Central website to read and post messages in this newsgroup. MATLAB Central is hosted by MathWorks.

Messages posted through the MATLAB Central Newsreader are seen by everyone using the newsgroups, regardless of how they access the newsgroups. There are several advantages to using MATLAB Central.

**One Account**

Your MATLAB Central account is tied to your MathWorks Account for easy access.

**Use the Email Address of Your Choice**

The MATLAB Central Newsreader allows you to define an alternative email address as your posting address, avoiding clutter in your primary mailbox and reducing spam.

**Spam Control**

Most newsgroup spam is filtered out by the MATLAB Central Newsreader.

**Tagging**

Messages can be tagged with a relevant label by any signed-in user. Tags can be used as keywords to find particular files of interest, or as a way to categorize your bookmarked postings. You may choose to allow others to view your tags, and you can view or search others’ tags as well as those of the community at large. Tagging provides a way to see both the big trends and the smaller, more obscure ideas and applications.

**Watch lists**

Setting up watch lists allows you to be notified of updates made to postings selected by author, thread, or any search variable. Your watch list notifications can be sent by email (daily digest or immediate), displayed in My Newsreader, or sent via RSS feed.

- Use a newsreader through your school, employer, or internet service provider
- Pay for newsgroup access from a commercial provider
- Use Google Groups
- Mathforum.org provides a newsreader with access to the comp.soft sys.matlab newsgroup
- Run your own server. For typical instructions, see: http://www.slyck.com/ng.php?page=2