problem in generate code using cftool

hi.i obtain mean of coloumn in matrix and curve fitting by cftool. then save generate code of it. but when I call it in the my code gives me an error message. What can I do?
% mean of matrix meanValue = mean(G);
x=1:1:47; y=meanValue; n=createFit(x,meanValue);
error is:
??? Error using ==> createFit Too many output arguments.
Error in ==> pixel at 35 n=createFit(x,meanValue);
thank you

Respuestas (1)

Geoff Hayes
Geoff Hayes el 22 de Mayo de 2014
Check the signature of the createFit function. Does it actually return something? i.e. if the signature is just:
function createFit(x,y)
then you will get the too many output arguments error since the above code is
n=createFit(x,meanValue);
i.e. the code is trying to get the return value of a function that does not return anything. There seems to be different versions of createFit on the MATLAB FileExchange and elsewhere too, so please verify that you are using the expected/correct version. I was able to reproduce your error using the code found at http://code.google.com/p/prosilica/source/browse/trunk/MATLAB/createFit.m?r=36

15 comentarios

fereshte
fereshte el 22 de Mayo de 2014
Editada: fereshte el 22 de Mayo de 2014
i typed cftool in workspace.this program gives me response with gauss 8 very well but when i saved generated code, i couldnt call it in my code. i write cftool in work space...then select x data and y data...and click create data set option...then in curve fitting tool window select fitting...new fit...type of fit(gaussian) and obtain coeffs.but i dont repeat for every image of database.That is why I choose from the options menu, generate code and run it, but gives error. your code uses Another way to fitting. i want to use gaussian fitting.
Geoff Hayes
Geoff Hayes el 22 de Mayo de 2014
What is the signature of your createFit function? Can you paste it here?
fereshte
fereshte el 22 de Mayo de 2014
please download my code from link
Geoff Hayes
Geoff Hayes el 22 de Mayo de 2014
Please just paste the signature for this function as that is what is interesting….
fereshte
fereshte el 22 de Mayo de 2014
Editada: fereshte el 22 de Mayo de 2014
this function not return something!!! x-y coordinate without anythings!
Right - the function does not return anything because it's signature is:
function createFit(x,y)
yet you have tried to assign a return value from this function to n:
n=createFit(x,meanValue);
hence the error message that was the reason for you posting this question on the board here.
fereshte
fereshte el 23 de Mayo de 2014
Now what do I do?
Image Analyst
Image Analyst el 23 de Mayo de 2014
You attach the file with the paperclip icon. What you don't do is upload your file to speedyshare that makes it cumbersome for people to help you.
Did you see where Geoff implied that you should have your function return a value by changing the "function" line?
fereshte
fereshte el 23 de Mayo de 2014
Editada: fereshte el 23 de Mayo de 2014
sorry.I dont know. i run Geoff code but tis error appear:
??? Undefined function or method 'createFit' for input arguments of type 'double'.
Error in ==> pixel at 35 createFit(x,y)
it is used from NonlinearLeastSquares but I'm using another method.
Geoff Hayes
Geoff Hayes el 23 de Mayo de 2014
fereshte - that wasn't my code for you to run, it was an example of the createFit function that someone else had posted with a signature that did not return any value…which was the original problem in your question with the error createFit Too many output arguments.
If you go back to using your original code without trying to get a return (or output value) from createFit, what is happening?
fereshte
fereshte el 23 de Mayo de 2014
my original code work very well but with curve fitting dont work!
It is no longer clear to me what the problem is. You had code, createFit, that doesn't return a value yet you tried to assign n to it. Or was it some other code that was calling your createFit function? If that is true, then you must provide an output/return value from your createFit function to satisfy the n in the line:
n=createFit(x,meanValue);
fereshte
fereshte el 23 de Mayo de 2014
ok.my original code isnt relevante to create fit.it is part of my project. create fit code generate by cftool.i dont write it.
Geoff Hayes
Geoff Hayes el 23 de Mayo de 2014
I think that we have covered why you were getting the error (that you posted). Is there something else that is preventing you from moving forward?
fereshte
fereshte el 24 de Mayo de 2014
Editada: fereshte el 24 de Mayo de 2014
no,just this.i want do curve fitting by gaussian in part of my project but i cannot..

Iniciar sesión para comentar.

Categorías

Más información sobre Get Started with Curve Fitting Toolbox en Centro de ayuda y File Exchange.

Preguntada:

el 22 de Mayo de 2014

Editada:

el 24 de Mayo de 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by