1
我對本人已寫入其內插的實驗值,也是曲線,該曲線擬合近似的內插數據Matlab的:錯誤矩陣尺寸
在i計算插值我是一個功能的改變的形狀分析建模獲得矩陣失配誤差,請您審查,並讓我知道我的我的錯誤
function [c_i,c_f,c_e] = M_shape_analysis(t,S,a1,a2,td,tmax,alpha,Be,p,q,r,k_el,k1,k2,k3)
%Modified Shape_analysis and estimating K3
% Interpolation of measured Data points
c_i = zeros(size(t));
ind = (t > td) & (t < tmax);
c_i(ind) = S *(1 - exp(-alpha*t(ind)));
%c_t(ind)= (A_max*K_1*(t(ind)/(k2+k3)-(td*(k2+k3)/(k2+k3).^2)-(td/(k2+k3) -(td*(k2+k3)/(k2+k3).^2))*exp(-(k2+k3)*(t(ind)-td)))+(0.5*K_2*(t(ind)-td).^2));
ind = (t >= tmax);
a3 =(S *(1 - exp(-alpha*t(ind))) -(a1+a2));
c_i(ind) = a1*exp(-p * (t(ind) - tmax))+ a2*exp(-q * (t(ind) - tmax)) + a3*exp(-r * (t(ind) - tmax));
%c_t(ind) =((K_1*(A/(k2+k3-B))*(exp(B*(t(ind)-tmax))- exp(-(k2+k3)*(t(ind)-tmax)))+(K_2*(A/B)*(1+exp(B*(t(ind)-tmax))))));
%ft = fittype('Input_function(t, a1, a2, a3, b1, b2, b3, td, tmax)', 'independent', 't');
%fo = fit(t, c, ft,'StartPoint', [20000, 20000, 20000, 0.01, 0.01, 0.01, 10, 30],'Lower', [0, 0, 0, 0, 0, 0, 0, 0]);
%plot(t,c_t);
hold all;
subplot(2, 2, 2);
plot(t, c_i,'x');
axis([0 50 -2000 80000]);
xlabel time ;
ylabel concentration ;
%--------------------------------------------------------------------------------------------------------------------------
% Fitting the measured Data
ind = (t > td) & (t < tmax);
c_f(ind)= conv(((t(ind) - td) ./ (tmax - td) * (a1 + a2 + a3)),(k1*exp(-(k2+k3)*t(ind)+((k1*k3)/(k2+k3-k_el)))),'same');
ind = (t >= tmax);
c_f(ind) = conv((a1 * exp(-b1 * (t(ind) - tmax))+ a2 * exp(-b2 * (t(ind) - tmax))) + a3 * exp(-b3 * (t(ind) - tmax)),(k1*exp(-(k2+k3)*t(ind)+((k1*k3)/(k2+k3-k_el)))),'same');
hold all;
subplot(2, 2,4);
plot(t, c_f);
axis([0 50 -2000 80000]);
xlabel time ;
ylabel concentration ;
%plot(ts, Input_function(ts, fo.a1, fo.a2, fo.a3, fo.b1, fo.b2, fo.b3, fo.td, fo.tmax));
%--------------------------------------------------------------------------------------------------------------------------
% Plotting K3 Estimate : Fitted curve
DV_free= k1/(k2+k3);
ind = (t >= tmax);
c_e(ind) = DV_free* exp(-Be*t(ind));
subplot(2, 2, 6);
plot(t, c_e);
axis([0 50 -2000 80000]);
xlabel time ;
ylabel concentration ;
end
下面是我獲得
Error using *
Inner matrix dimensions must agree.
Error in M_shape_analysis (line 17)
c_i(ind) = a1*exp(-p * (t(ind) - tmax))+ a2*exp(-q * (t(ind) - tmax)) + a3*exp(-r *
(t(ind) - tmax));
錯誤
請讓我知道我在我的模型中的錯誤位置
上一行中a3的定義將在length(ind)> 1時產生一個數組。所以'a3 * exp(...)'會給你一個錯誤。使用'。*'代替 –
@ R.Schifini非常感謝,效果很好 – DevanDev