こんにちは私はMATLABを初めて使用します。文字列を関数にするには、どうすればよいか知りたいと思いました。標準のMatlab形式のユーザーから文字列として関数にアクセスしたい(例exp(-10*X)-sin(pi*X)-2*tanh(X)
)ここで、Xは変数です。次に、「X」を「low」および「high」変数に置き換えて、これらの制限での関数の値を計算します。私はこの目的のために「strrep」を使用しました。次のエラーが発生します1)未定義の関数または変数「X」。2)「X」が「low」と「high」に置き換えられたかどうかがわかりません。
どんな助けでも本当にありがたいです。以下は私のコードです。
high=input('Upper Limit of the Interval : ');
low=input('\nLower Limit of the interval : ');
usr_funct=input('Enter The Function in standard Matlab Format.\nEnter "X" for the
variable and * for multiply \n'); % Example exp(-10*X)-sin(pi*X)-2*tanh(X);
middle = (low+high)/2;
Flow =strrep(usr_funct, 'X', 'low');
Fhigh =strrep(usr_funct, 'X', 'high');
sprintf('Flow '); % This was to check if 'X' was replaced with 'low'. It is not printing anything