Error using arrayfun All of the input arguments must be of the same size and shape

8 ビュー (過去 30 日間)
Gabor Riccardi
Gabor Riccardi 2021 年 9 月 23 日
編集済み: Fangjun Jiang 2021 年 9 月 23 日
I am trying to convert to binary numbers in a string with this code:
sbox=[12;5;6;11;9;0;10;13;3;14;15;8;4;7;1;2];
f=@(x) dec2bin(x,4);
l=arrayfun(f,sbox,'UniformOutpot',false);
But i get the following error
Error using arrayfun
All of the input arguments must be of the same size and shape.
Previous inputs had size 16 in dimension 1. Input #3 has size 1
Error in nl (line 3)
l=arrayfun(f,sbox,'UniformOutpot',false);
I also tried to input sbox=[1,1,1] but it gives me the same error

回答 (2 件)

Benjamin
Benjamin 2021 年 9 月 23 日
Change 'UniformOutpot' to 'UniformOutput' so that MATLAB doesn't think it's another input variable for f.

Fangjun Jiang
Fangjun Jiang 2021 年 9 月 23 日
編集済み: Fangjun Jiang 2021 年 9 月 23 日
no need to use arrayfun() for this.
cellstr(dec2bin(sbox,4))

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by