Sample関数について, 数列をランダムに生成する方法
Afficher commentaires plus anciens
状態遷移関数から「天気」の数列をランダムに生成したいと考えているのですが、 以下のコードですとsample関数がうまく機能していないようなのでが、 何が問題かご存知の方教えて頂けると幸いです。
以下コード;
X_today = [ 0 1 0 ]'; % Cloudy
T = [ 8 2 0 ; 4 4 2 ; 2 6 2 ]' / 10;
X_tomorrow = sample( T * X_today );
if ( X_tomorrow(1) == 1 )
disp( 'sunny' );
elseif ( X_tomorrow(2) == 1 )
disp( 'cloudy' );
elseif ( X_tomorrow(3) == 1 )
disp( 'rainy' );
end
以下エラー;
関数または変数 'sample' が未定義です。
エラー: HW2_2 (line 5)
X_tomorrow = sample( T * X_today );
Réponses (1)
その手のエラーメッセージは一番良く出る基本的なエラーメッセージです。 ドキュメンテーションのこのページをご覧になって対処してみて下さい。
2 commentaires
Naoki Ishibashi
le 8 Fév 2017
michio
le 9 Fév 2017
sampleという関数はMATLABの製品群の中には無いようですので、関数だとすればどなたかが独自に作られたものという可能性が高いですね。sample関数(もしくは変数)を使ったプログラムが Ishibashiさんの書かれたものでなければ、製作者に問い合わせるのが最も確実ですね。
数列をランダムに生成、というだけではなく X_tomorrow (出力)と T*X_today (入力)が明確に分かれば、他の関数を使って実装する道も見えてきます。
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!