error using tranpose (recieving permute error )

CODE:
%% Testing Phase
load('testFeatures');
featvales=b2{1};
label=b2{2};
num_dims = max(size(featvales));
X=featvales';
Y=label';
PROBLEM:
I have to calculate the average for 2 different dimension
1st for 10 dimensional function
2nd for 30 dimensional function
ERROR :(the following error is recieved while executing the code)
Error using '
Transpose on ND array is not defined. Use PERMUTE instead.
Error in FeatureSelection (line 28)
X=featvales';

2 件のコメント

Walter Roberson
Walter Roberson 2023 年 7 月 26 日
num_dims = max(size(featvales));
That is incorrect.
num_dims = ndims(featvales);
Meetul Choudhary
Meetul Choudhary 2023 年 7 月 27 日
still getting the same error

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

 採用された回答

Fangjun Jiang
Fangjun Jiang 2023 年 7 月 26 日

0 投票

The error message is clear. How do you transpose a three (or more) dimension array?
a=rand(2,3);
a';
a=rand(2,3,4);
a';
Error using '
TRANSPOSE does not support N-D arrays. Use PAGETRANSPOSE/PAGECTRANSPOSE to transpose pages or PERMUTE to reorder dimensions of N-D arrays.

7 件のコメント

Meetul Choudhary
Meetul Choudhary 2023 年 7 月 26 日
Error using '
Transpose on ND array is not defined. Use PERMUTE instead.
Error in FeatureSelection (line 29)
X';
I'm still getting this error. Is there a way we can connect and discuss this code?
Fangjun Jiang
Fangjun Jiang 2023 年 7 月 26 日
What is the return value of size(X)?
Your array "X" must be a multi-dimenstion array. In that case, you can't do transpose(X).
Meetul Choudhary
Meetul Choudhary 2023 年 7 月 27 日
Fangjun Jiang
Fangjun Jiang 2023 年 7 月 27 日
編集済み: Fangjun Jiang 2023 年 7 月 27 日
add this line before doing the transpose. You will see it removes the two dimensions of length 1.
featvales=squeeze(featvales);
size(featvales)
Meetul Choudhary
Meetul Choudhary 2023 年 7 月 27 日
Fangjun Jiang
Fangjun Jiang 2023 年 7 月 27 日
Then you should be able to do featvales'
Meetul Choudhary
Meetul Choudhary 2023 年 7 月 28 日
編集済み: Meetul Choudhary 2023 年 7 月 28 日
can you connect to me personally @mahimitulmahi1@gmail.com

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

その他の回答 (1 件)

James Tursa
James Tursa 2023 年 7 月 26 日
編集済み: James Tursa 2023 年 7 月 26 日

0 投票

If you are trying to transpose the initial 2D pages of your variable, you can do this:
pagetranspose(featvales)
Or this:
d = 1:ndims(featvales)
permute(featvales,[2,1,d(3:end)])
But it isn't clear if this will fix your underlying problem.

2 件のコメント

Meetul Choudhary
Meetul Choudhary 2023 年 7 月 27 日
what exactly does this output gives as output?
it is showing a value for (:, :, 1, 704) to (:, :, 1000, 704)
Meetul Choudhary
Meetul Choudhary 2023 年 7 月 27 日
I am working on feature selection where im facing this issue in a part of code

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

カテゴリ

製品

リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by