I can't take several non-linear inputs and assign them names for using later in the code.
1 回表示 (過去 30 日間)
古いコメントを表示
I am trying to do the following operation:
a=input('Enter the no. of equations');
counter=1;
while counter<=a
f_counter=input('enter the equation','s');
F(counter)=f_counter;
counter=counter+1;
end
F is a row vector ,supposed to be,changing size and storing the non-linear equations entered by the user. The problem is 'f_counter' is being considered as a single name instead of f_1 , f_2 etc. I am writing a code for Newton's method for non-linear equations(if that helps).
0 件のコメント
採用された回答
Matt J
2014 年 11 月 5 日
編集済み: Matt J
2014 年 11 月 5 日
The problem is 'f_counter' is being considered as a single name instead of f_1 , f_2 etc.
Even if 'f_counter' did what you were hoping, it would (a) be bad coding practice and (b) serve no purpose because you are putting the input in F anyway. There's no reason the inputs have to be held in 2 places, as far as I can see. However, F needs to be a cell array as below
a=input('Enter the no. of equations');
counter=1;
while counter<=a
F{counter}=input('enter the equation','s');
counter=counter+1;
end
7 件のコメント
Matt J
2014 年 11 月 6 日
編集済み: Matt J
2014 年 11 月 6 日
Well, for a full understanding, you'll probably need to read up on cell array manipulation,
However, you can also gain an understanding of what my commands are doing by running them individually at the command line and displaying their output. For example, below you can see that F(:,2)={'; '} is just adding a column of semicolons to the original F,
>> F={'x+y';'x*y'}, F(:,2)={'; '},
F =
'x+y'
'x*y'
F =
'x+y' '; '
'x*y' '; '
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Assumptions についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!