フィルターのクリア

Error using repmat function

5 ビュー (過去 30 日間)
Nik Sam
Nik Sam 2016 年 5 月 12 日
コメント済み: Walter Roberson 2016 年 5 月 25 日
Error using repmat
Replication factors must be a row vector of integers or integer scalars.
Can anyone tell me why i get this error when I am trying to use
x{i} = repmat(shiftdim(varargin{i}(j,:),1-i),repvec);
  2 件のコメント
Walter Roberson
Walter Roberson 2016 年 5 月 12 日
What is in repvec ? What is class(repvec) ?
Nik Sam
Nik Sam 2016 年 5 月 13 日
編集済み: Walter Roberson 2016 年 5 月 13 日
function fzr = rtrm(func, varargin)
% RTRM Fast, vectorized implementation of the
reduced transformation method
% using multi-dimensional arrays.
% FZR = RTRM(FUNC, FZ1, FZ2, ..., FZN)
% calls the reduced transformation method
% with N fuzzy numbers in alpha-cut repre-
% sentation. The function FUNC must be an
% analytical expression using \textsc{Matlab}'s
% array arithmetic (or logic) operators.
%
% Example:
% f = inline('x.^2 - y');
% fz1 = [0 5; 1 4; 2 3; 2.5 2.5];
% fz2 = [1 3; 1.5 2.5; 1.75 2.25; 2 2];
% fzr = rtrm(f, fz1, fz2)
% plot(fzr,linspace(0,1,4))
n = nargin - 1;
m = size(varargin{1},1) - 1;
fzr = repmat([inf -inf],m+1,1);
for j = m+1:-1:1
for i = 1:n
repvec = 2*ones(n,1);
repvec(i) = 1;
x{i} = repmat(shiftdim(...
varargin{i}(j,:)',1-i),repvec);
end
z = reshape(feval(func,x{:}),2^n,1);
fzr(j,1) = min(min(z),fzr(min(j,m)+1,1));
fzr(j,2) = max(max(z),fzr(min(j,m)+1,2));
end
This all the code

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 5 月 13 日
Where you have
repvec = 2*ones(n,1);
change that to
repvec = 2*ones(1,n);
  2 件のコメント
Nik Sam
Nik Sam 2016 年 5 月 13 日
Now I get this.Why?
Error using inlineeval (line 14)
Error in inline expression ==> x.^2 - y
Matrix dimensions must agree.
Error in inline/feval (line 33)
INLINE_OUT_ = inlineeval(INLINE_INPUTS_, INLINE_OBJ_.inputExpr, INLINE_OBJ_.expr);
Error in rtrm (line 27)
z = reshape(feval(func,x{:}),2^n,1);
Walter Roberson
Walter Roberson 2016 年 5 月 25 日
With just the change I mentioned, I get results. I have enclosed the edited file. I tested with
f = inline('x.^2 - y');
fz1 = [0 5; 1 4; 2 3; 2.5 2.5];
fz2 = [1 3; 1.5 2.5; 1.75 2.25; 2 2];
fzr = rtrm(f, fz1, fz2)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDebugging and Analysis についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by