필터 지우기
필터 지우기

Dimension Disagree issue ?

조회 수: 1 (최근 30일)
shawin
shawin 2022년 3월 31일
댓글: shawin 2022년 4월 4일
Hi,
I have the code below :
% 2D Data
sample1 = [ ( 75.2 - 32 ).*rand( 1, 20 ) + 32, ...
( 60 - 20 ).*rand( 1,20 ) + 20, ...
( 15 -( -3.4 ) ).*rand( 1, 20 ) + ( -3.4 )
]';
sample2 = [ ( 19.2 - 1 ).*rand( 1,20 ) + 1, ...
( -10 - ( -42.5 ) ).*rand( 1,20 ) + ( -42.5 ), ...
( 20.4 - ( -5 ) ).*rand( 1,20 ) + ( -5 )
]';
inputs = [ sample1, sample2 ];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
nClusters=3;
fuzzification=2;
[nInputs, nInputSamples ] = size( inputs );
% Number of Clusters
nC = nClusters;
% fuzzification parameter
m = fuzzification;
% Generate the random association of inputs to the clusters, values [ 0, 1 ]
n = rand( nInputs, nC );
nTotal = sum( n, 2 );
RandomAssociationValues = ( n./nTotal );
when i run it , i recieved an error which is :
kindly , how can i fix this issue???
Error using ./
Matrix dimensions must agree.

채택된 답변

Chunru
Chunru 2022년 3월 31일
Your code can run without issue as show below.
Try "clear all;" before running the code. Or you can step through your code to see where the code goes wrong.
% 2D Data
sample1 = [ ( 75.2 - 32 ).*rand( 1, 20 ) + 32, ...
( 60 - 20 ).*rand( 1,20 ) + 20, ...
( 15 -( -3.4 ) ).*rand( 1, 20 ) + ( -3.4 )
]';
sample2 = [ ( 19.2 - 1 ).*rand( 1,20 ) + 1, ...
( -10 - ( -42.5 ) ).*rand( 1,20 ) + ( -42.5 ), ...
( 20.4 - ( -5 ) ).*rand( 1,20 ) + ( -5 )
]';
inputs = [ sample1, sample2 ];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
nClusters=3;
fuzzification=2;
[nInputs, nInputSamples ] = size( inputs );
% Number of Clusters
nC = nClusters;
% fuzzification parameter
m = fuzzification;
% Generate the random association of inputs to the clusters, values [ 0, 1 ]
n = rand( nInputs, nC );
nTotal = sum( n, 2 )
nTotal = 60×1
1.5271 1.6793 1.5102 1.7007 1.6301 1.6533 1.1795 1.5919 2.6963 1.5790
RandomAssociationValues = ( n./nTotal );
  댓글 수: 2
shawin
shawin 2022년 3월 31일
편집: shawin 2022년 3월 31일
No, the error is with :
RandomAssociationValues = ( n./nTotal );???
Error using ./
Matrix dimensions must agree.
Matlab version is : 2016a
shawin
shawin 2022년 4월 4일
The code is working with Matlab 2022

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

제품


릴리스

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by