我有一個代碼來測試一個網絡的OCR過程。 這:如何將矢量轉換爲標量,用於switch語句?
%% Set new target data (data testing) data2 = fetest8; % data2 = fetest2; % data2 = fetest3; targetx = zeros(1,204); targetx (:,1:50) = 1; targetx (:,51:52) = 2; targetx (:,53:62) = 3; targetx (:,63:82) = 4; targetx (:,83) = 5; targetx (:,84:85) = 6; targetx (:,86:92) = 7; targetx (:,93:95) = 8; targetx (:,96:105) = 9; targetx (:,106) = 10; targetx (:,107:111) = 11; targetx (:,112:116) = 12; targetx (:,117:126) = 13; targetx (:,127:176) = 14; targetx (:,177) = 15; targetx (:,178:180) = 16; targetx (:,181) = 17; targetx (:,182:201) = 18; targetx (:,202:204) = 19;
prediksi = round(sim (net, data2)); %contain target in matrix, data type: double
switch (prediksi)
case '1'
fprintf ('Alif\n');
case '2'
fprintf ('Baa\n');
case '3'
fprintf ('Haaa\n');
case '4'
fprintf ('Daal\n');
case '5'
fprintf ('Raa\n');
case '6'
fprintf ('Siin\n');
case '7'
fprintf ('Saad\n');
case '8'
fprintf ('Thaaa\n');
case '9'
fprintf ('Ayn\n');
case '10'
fprintf ('Faa\n');
case '11'
fprintf ('Gaaf\n');
case '12'
fprintf ('Kaaf\n');
case '13'
fprintf ('Laam\n');
case '14'
fprintf ('Miim\n');
case '15'
fprintf ('Nuun\n');
case '16'
fprintf ('Haa\n');
case '17'
fprintf ('Waaw\n');
case '18'
fprintf ('Yaa\n');
case '19'
fprintf ('Kaaf\n');
otherwise
fprintf ('X\n');
end
1直至204,prediksi 1x24雙。
我得到這個錯誤:'SWITCH表達式必須是標量或字符串常量。' 如何解決這個錯誤?
任何幫助將非常感激。
'sim(net,data2)'輸出是什麼? – Dan