Hi , I am very new to Matlab, so I am facing some problems. Would u mind give me a bit of help?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
My problem is that i cant run this function on curve fitting toolbox
The script i want to run:
%x,y,z are matrices of same size
function z=fc1(x,y,theta)
for i=1:size(x)
z=((1-x)^theta+(1-y)^theta-1)^(-1/theta)+x+y-1;
end
end
How can i run it into curve fitting so i can reach theta value?
0 Kommentare
Antworten (1)
Javier Bastante
am 16 Mär. 2016
Function solve can help you here. Your input in that function can be symbolic variables or string variables, so thats what we are going to do. Transform each value of your matrices into a string and get each value of theta, your OUTPUT value, that's why your first line must change:
function theta=fc1(x,y,z)
%x,y,z are matrices of same size and must be your INPUT values
theta=[]; %We must initialize the variable
%Size gives you two values. Length is used for rows and columns
%For two dimensional arrays use a "for" for columns and another one for rows
for i=1:length(x),
solution=solve([num2str(z(i)) '=((1-' num2str(x(i)) ')^theta+(1-' num2str(y(i)) ')^theta-1)^(-1/theta)+' num2str(x(i)) '+' num2str(y(i)) '-1','theta');
solution=double(solution); %Just to get the solution as a number, and not as symbolic
theta(i)=solution; %Finally we introduce the obtained value on its place
end
end
Hope it works. Regards
0 Kommentare
Siehe auch
Kategorien
Mehr zu Curve Fitting Toolbox finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!