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

select_model2(PP,mode,avail)
function select = select_model2(PP,mode,avail)
%select_model
%select_model(PP,mode,avail)
%this function selects the number of the right model 
%(modelZA modelMAe modelMAn modelMAp modelETA modelKSI)=(1 2 3 4 5 or 6) 
%to be handled. For a given performance parameter PP 
%(1=traction force, 2=efficiency, 3=assistance factor) and
%assistance modes (what=[ZA MAe MAn MAp])  are given. 
%The matrix avail, tells which models are found (modelZA modelMAe modelMAn modelMAp modelETA modelKSI) 
%avail=[modelZA modelMAe modelMAn modelMAp modelETA modelKSI].
%mode is a 1x4 matrix (e.g. 1 0 0 1) with the asked assistance modes


if or(PP==1,PP==5)
    for k=1:4
        if sum(mode)==0
            errordlg('Their are no assistance modes selected to plot','Bad Input','modal')
            select=[0 0 0 0 0 0];
            break
        elseif and(avail(k)==1,mode(k)==1)
        select(k)=1;
        elseif and(avail(k)==1,mode(k)==0)
           select(k)=0;
        elseif and(avail(k)==0,mode(k)==1)
           errordlg('No data available for (all of) the desired plot(s)','Bad Input','modal')
           select=[0 0 0 0 0 0];
            break
        end
        if sum(mode(1:4))>sum(avail(1:4))
           errordlg('No data available for (all of) the desired plot(s)','Bad Input','modal') 
           select=[0 0 0 0 0 0];
            break
        end
    end
  for k=5:6
    select(k)=0;
  end
  if sum(select(1:4))>sum(avail(1:4))
         errordlg('No data available for (all of) the desired plot(s)','Bad Input','modal')
         select=[0 0 0 0 0 0];
 end
elseif PP==2
    if sum(mode)>1
        errordlg('The efficiency plots are only defined in the zero assistance mode','Bad Input','modal')
        select=[0 0 0 0 0 0];
    elseif sum(mode)==0
        errordlg('The Zero Assistance Mode has to be selected to show the efficiency','Bad Input','modal')
        select=[0 0 0 0 0 0];
    elseif mode(1)==0
        errordlg('The efficiency plots are only defined in the zero assistance mode','Bad Input','modal')
        select=[0 0 0 0 0 0];
    else
    select=[0 0 0 0 1 0];
    end
elseif PP==3
    if avail(6)==1
       select=[0 0 0 0 0 1];
    else 
        errordlg('The assistance plots are not available for this pedelec','Bad Input','modal')
        select=[0 0 0 0 0 0];
    end
elseif PP==0
      errordlg('Please select a performance parameter','Bad Input','modal')
      select=[0 0 0 0 0 0];
elseif PP==4
    for k=1:4
        if sum(mode)==0
            errordlg('Their are no assistance modes selected to plot','Bad Input','modal')
            select=[0 0 0 0 0 0];
            break
        elseif and(avail(k)==1,mode(k)==1)
        select(k)=1;
        elseif and(avail(k)==1,mode(k)==0)
           select(k)=0;
           elseif and(avail(k)==0,mode(k)==1)
           errordlg('No data available for (all of) the desired plot(s)','Bad Input','modal')
           select=[0 0 0 0 0 0];
            break
        end
        if sum(mode(1:4))>sum(avail(1:4))
           errordlg('No data available for (all of) the desired plot(s)','Bad Input','modal') 
           select=[0 0 0 0 0 0];
            break
        end
        for k=5:6
            select(k)=0;
        end
          if sum(select(1:4))>sum(avail(1:4))
                 errordlg('No data available for (all of) the desired plot(s)','Bad Input','modal')
                 select=[0 0 0 0 0 0];
          end
    end
end


Contact us at files@mathworks.com