function [ output ] = myerror( x ) %MYERROR Summary of this function goes here % Detailed explanation goes here global tcut datacut Trt rho=x(1); k=x(2); pc0=x(3); t0=x(4); mydata=pc0/(rho-k)^2*((1-k)*rho.^((tcut-t0)/Trt)-(1-rho)*k.^((tcut-t0)/Trt)).^2; output=sum((mydata-datacut).^2); end