給你寫了下A=[1 2 3 ;4 5 6 ;7 8 9];B=dec2bin(A)%將A轉為二進位制C=cell(size(A))%由於得到的B的形狀與A不同,我們建立一個新的元胞資料Cfor i=1:length(B)C=B(i,:);%得到的C就與A的形狀一樣了endD=cell(size(A));%再建立兩個元胞矩陣,分別存放奇數與偶數項E=cell(size(A));for i=1:length(B)D=C(1:2:end);%D為奇數項E=C(2:2:end);%E為偶數項 end結果:A = 1 2 3 4 5 6 7 8 9>> BB =000101000111001001011000001101101001>> CC = "0001" "0010" "0011" "0100" "0101" "0110" "0111" "1000" "1001">> DD = "00" "01" "01" "00" "00" "01" "01" "10" "10">> EE = "01" "00" "01" "10" "11" "10" "11" "00" "01"
給你寫了下A=[1 2 3 ;4 5 6 ;7 8 9];B=dec2bin(A)%將A轉為二進位制C=cell(size(A))%由於得到的B的形狀與A不同,我們建立一個新的元胞資料Cfor i=1:length(B)C=B(i,:);%得到的C就與A的形狀一樣了endD=cell(size(A));%再建立兩個元胞矩陣,分別存放奇數與偶數項E=cell(size(A));for i=1:length(B)D=C(1:2:end);%D為奇數項E=C(2:2:end);%E為偶數項 end結果:A = 1 2 3 4 5 6 7 8 9>> BB =000101000111001001011000001101101001>> CC = "0001" "0010" "0011" "0100" "0101" "0110" "0111" "1000" "1001">> DD = "00" "01" "01" "00" "00" "01" "01" "10" "10">> EE = "01" "00" "01" "10" "11" "10" "11" "00" "01"