资源简介
函数调用,在MATLAB粒子群工具箱中,代码可以利用此函数完善求解
代码片段和文件信息
function [outvarargout]=normmat(xnewminmaxflag)
% normmat.m
% takes a matrix and reformats the data to fit between a new range
%
% Usage:
% [xprimeminsmaxs]=normmat(xrangemethod)
%
% Inputs:
% x - matrix to reformat of dimension MxN
% range - a vector or matrix specifying minimum and maximum values for the new matrix
% for method = 0 range is a 2 element row vector of [minmax]
% for method = 1 range is a 2 row matrix with same column size as
% input matrix with format of [min1min2...minN;
% max1max2...maxM];
% for method = 2 range is a 2 column matrix with same row size as
% input matrix with format of [min1max1;
% min2max2;
% ... ...;
% minMmaxM];
% alternatively for method 1 and 2 can input just a 2 element vector as in method 0
% this will just apply the same min/max across each column or row respectively
% method - a scalar flag with the following function
% = 1 normalize each column of the input matrix separately
% = 2 normalize each row of the input matrix separately
% = 0 normalize matrix globally
% Outputs:
% xprime - new matrix normalized per method
% minsmaxs - optional outputs return the min and max vectors of the original matrix x
% used for recovering original matrix from xprime
%
% example: x = [-1030;24.1-7;3.410.01]
% [xprimeminsmaxs]=normmat(x[010]0)
% Brian Birge
% Rev 2.1
% 3/16/06 - changed name of function to avoid same name in robust control
% toolbox
%--------------------------------------------------------------------------------------------------------
if flag==0
a=min(min((x)));
b=max(max((x)));
if abs(a)>abs(b)
large=a;
small=b;
else
large=b;
small=a;
end
temp=size(newminmax);
if temp(1)~=1
error(‘Error: for method=0 range vector must be a 2 element row vector‘);
end
den=abs(large-small);
range=newminmax(2)-newminmax(1);
- 上一篇:Spwm变频调速283895
- 下一篇:永磁同步电动机转速电流双闭环调速系统仿真
评论
共有 条评论