function [grad] = scaleGrad(grad, scale, system) % scaleGrad just scales the gradint with the scalar % if the optional parameter 'system' is provided the result is schecked % against the system limits (amolityde and slew rate) if isfield(grad,'id') error('attempting to scale readily registered object! please register objects after calling this function or deregister the argument by calling rmfield(...,''id'')'); end if strcmp(grad.type,'trap') grad.amplitude=grad.amplitude*scale; grad.area=grad.area*scale; grad.flatArea=grad.flatArea*scale; if nargin>2 if system.maxGradeps && system.maxSlew2 if system.maxGradeps grad_max_abs_slew=max(abs(diff(grad.waveform)./diff(grad.tt))); if system.maxSlew