fit with a user-defined function in matlab, error: Custom equations must produce an output vector, matrix,

3 views (last 30 days)
I'm try to make a fit with a user defined function. The result of the function is an element of a matrix. The function is built in a such a way that even if the input is an array the output is still an array, containing the element of the matrix.
When I try to use it or in Curve fit toolbox or directly in a program I obtain the following error message:
Custom equations must produce an output vector, matrix, or array that is the same size and shape as the input data
If I type my function directly at Matlab prompt I obtain the right results, both if I put one input that an array of values.
Just to add some lines:
Q1(:,:,j) = [cos(Lq1eff*arg(j)) , sin(Lq1eff*arg(j))/arg(j) , 0 ,0 ,0,0;
-arg(j)*sin(Lq1eff*arg(j)) , cos(Lq1eff*arg(j)) , 0 ,0 ,0,0;
0 , 0 ,cosh(Lq1eff*arg(j)) ,sinh(Lq1eff*arg(j))/arg(j),0,0;
0 , 0 ,arg(j)*sinh(Lq1eff*arg(j)),cosh(Lq1eff*arg(j)) ,0,0;
0 , 0 , 0 ,0 ,1,0;
0 , 0 , 0 ,0 ,0,1];
This is the matrix, everything is defined and non zero or infinity. The output is for j=1:length(currents) RTransport11(j)=Q1(1,1,j); end
currents is the input array. How can I solve this problem?
Best Regards Alessandro Cianchi

Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!