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 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

产品


版本

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by