Curve fitting with multiple variables?
I have three different curves for S=2, S=1 and S=0.5 as shown in Figure below. The Book1.xlsx is attached.
I want to use curve fitting to find out one common equation such as, HF = f(S,T).
I used the following comman line to get the equation which I got from previous post (link). But I am getting following error:
Error using nlinfit (line 213)
Error evaluating model function ‘@(b,x)exp(b(1)).*x(:,1).^b(2)+b(3).*x(:,2)
What should I do? Is there any other better method as well?
T1 = readtable(‘Book1.xlsx’, ‘VariableNamingRule’,’preserve’)
VN = T1.Properties.VariableNames
Viv = regexp([VN{:}], ‘(d*.d*)|d*’, ‘match’)
Viv = str2double(Viv)
Viym = T1{:,2:4};
Viyv = Viym(:); % ‘Vi’ Vector
Vivm = repmat(Viv, size(T1,1), 1);
Vivv = Vivm(:); % ‘Viv’ Vector
y = Viyv;
SoCv = repmat(T1.T, size(Viym,2), 1) % ‘SoC’ Vector
x = [SoCv Vivv]; % Concatenate Vectors
objfcn = @(b,x) exp(b(1)).*x(:,1).^b(2) + b(3).*x(:,2);
mdl = fitnlm(x, y, objfcn, rand(3,1))I have three different curves for S=2, S=1 and S=0.5 as shown in Figure below. The Book1.xlsx is attached.
I want to use curve fitting to find out one common equation such as, HF = f(S,T).
I used the following comman line to get the equation which I got from previous post (link). But I am getting following error:
Error using nlinfit (line 213)
Error evaluating model function ‘@(b,x)exp(b(1)).*x(:,1).^b(2)+b(3).*x(:,2)
What should I do? Is there any other better method as well?
T1 = readtable(‘Book1.xlsx’, ‘VariableNamingRule’,’preserve’)
VN = T1.Properties.VariableNames
Viv = regexp([VN{:}], ‘(d*.d*)|d*’, ‘match’)
Viv = str2double(Viv)
Viym = T1{:,2:4};
Viyv = Viym(:); % ‘Vi’ Vector
Vivm = repmat(Viv, size(T1,1), 1);
Vivv = Vivm(:); % ‘Viv’ Vector
y = Viyv;
SoCv = repmat(T1.T, size(Viym,2), 1) % ‘SoC’ Vector
x = [SoCv Vivv]; % Concatenate Vectors
objfcn = @(b,x) exp(b(1)).*x(:,1).^b(2) + b(3).*x(:,2);
mdl = fitnlm(x, y, objfcn, rand(3,1)) I have three different curves for S=2, S=1 and S=0.5 as shown in Figure below. The Book1.xlsx is attached.
I want to use curve fitting to find out one common equation such as, HF = f(S,T).
I used the following comman line to get the equation which I got from previous post (link). But I am getting following error:
Error using nlinfit (line 213)
Error evaluating model function ‘@(b,x)exp(b(1)).*x(:,1).^b(2)+b(3).*x(:,2)
What should I do? Is there any other better method as well?
T1 = readtable(‘Book1.xlsx’, ‘VariableNamingRule’,’preserve’)
VN = T1.Properties.VariableNames
Viv = regexp([VN{:}], ‘(d*.d*)|d*’, ‘match’)
Viv = str2double(Viv)
Viym = T1{:,2:4};
Viyv = Viym(:); % ‘Vi’ Vector
Vivm = repmat(Viv, size(T1,1), 1);
Vivv = Vivm(:); % ‘Viv’ Vector
y = Viyv;
SoCv = repmat(T1.T, size(Viym,2), 1) % ‘SoC’ Vector
x = [SoCv Vivv]; % Concatenate Vectors
objfcn = @(b,x) exp(b(1)).*x(:,1).^b(2) + b(3).*x(:,2);
mdl = fitnlm(x, y, objfcn, rand(3,1)) curve fitting, regression, interpolation, variables MATLAB Answers — New Questions