スレッシュホールド(0.5ではなく)を超えていれば丸められ、それ以外の場合は丸められます。カスタム・スレッショルドで数値を丸める
ここに私が思いついたコードがあります。これは、またはより洗練されたソリューション(おそらくベクトル化された)のためのmatlabの関数が組み込まれていますか?
function [ rounded_numbers ] = custom_round(input_numbers, threshold)
%CUSTOM_ROUND rounds between 0 and 1 with threshold threshold
[input_rows, input_cols] = size(input_numbers);
rounded_numbers = zeros(input_rows, input_cols);
for i = 1:length(input_numbers)
if input_numbers(i) > threshold
rounded_numbers(i) = 1;
else
rounded_numbers(i) = 0;
end
end
end
おかげ
wow私はばかです。ありがとう – waspinator
@waspinator:常に助けてくれてうれしいです:P – Jonas