No BSD License  

Highlights from
GUI for the performance analysis of pedelecs

image thumbnail
from GUI for the performance analysis of pedelecs by Jan Cappelle
Modeling the behaviour of electric bicycles

CreateKSImodels(models)
function model = CreateKSImodels(models)

%model.X is the vector where ksi is calculated
%model.ksi is the matrix of size length(grid)x3 with the assistance factors
%model.MAM is a vector [x x x] with x=0/1 if the [MAe MAn MAp] exist.
%if a certain assistance mode doesn't exist the ksi was put to zero in
%every point
%model.RMSE=the RMSE of the ksimodel!
%The needed input is the models of the given bicycle, the testdataZA and
%the RMSEs of the models of the given bicycle.

if not(isstruct(models))
    errordlg('There something wrong with the models structure in the given directory','bad input','modal')
elseif isfield(models,'ZA')
    %create a list with available models
    modellist=fieldnames(models);
    comparelist={'ZA','MAe','MAn','MAp','ETA','KSI'};
    for k=1:length(comparelist)
        if sum(strcmp(modellist,comparelist(k)))~=0
            avail(k)=1;
        else
            avail(k)=0;
        end
    end
    MAM=avail(2:4);
    sumMAM=sum(avail(2:4));
    if MAM==0
        errordlg('Please create first the available motor assistance models','bad input','modal')
    else
        %new grid
        vmax=25;
        Tmax=80;
        deltav=0.5;
        deltaT=0.5;
        vgrid = 0:deltav:vmax;
        Tgrid = 0:deltaT:Tmax;
        for k=1:length(vgrid)
        hulp(((k-1)*(length(Tgrid))+1):k*length(Tgrid),:)=[vgrid(k).*ones(length(Tgrid),1) Tgrid'];
        end
        Xnew = hulp;
        %XtestZA=testdataZA(:,1:2);
        YnewZA=simlssvm(models.ZA,Xnew);
            if avail(2)==1
            Ynew(:,1) = simlssvm(models.MAe,Xnew);
            %Ytest(:,1)= simlssvm(models.MAe,XtestZA);
                for i=1:length(Xnew(:,1))
                    ksi(i,1)=1-YnewZA(i)/Ynew(i,1);
                    %ksitest(i,1)=1-YtestZA(i)/Ytest(i,1);
                end
            else
                for i=1:length(Xnew)
                    ksi(i,1)=0;
                    %ksitest(i,2)=0;
                end
            end
            if avail(3)==1
            Ynew(:,2) = simlssvm(models.MAn,Xnew);
            %Ytest(:,2)= simlssvm(models.MAn,XtestZA);
                for i=1:length(Xnew)
                    ksi(i,2)=1-YnewZA(i)/Ynew(i,2);
                    %ksitest(i,2)=1-YtestZA(i)/Ytest(i,2);
                end
            else
            for i=1:length(Xnew)
                ksi(i,2)=0;
                %ksitest(i,2)=0;
            end
            end
            if avail(4)==1
            Ynew(:,3) = simlssvm(models.MAp,Xnew);
            %Ytest(:,3)= simlssvm(models.MAp,XtestZA);
                for i=1:length(Xnew)
                    ksi(i,3)=1-YnewZA(i)/Ynew(i,3);
                    %ksitest(i,3)=1-YtestZA(i)/Ytest(i,3);
                end
            else
            for i=1:length(Xnew)
                ksi(i,3)=0;
                %ksitest(i,3)=0;
            end
            end
            %filter negative and unrealistic ksi 
            for i=1:length(Xnew(:,1))
                for j=1:3
                    if or(ksi(i,j)>1,ksi(i,j)<0)
                        ksi(i,j)=NaN;
                    end
                end
            end
    end
        model=struct;
        model.X=Xnew;
        model.ksi=ksi;
        model.MAM=MAM;
              
        
else
    errordlg('There should be at least one model without motor assistance and one model with motor assistance available in the given directory','bad input','modal')
end

Contact us