hello. i need a way to have the user input an equation as a variable and then have it evaluate that function at various points during a for loop. please help
K=input('input equation') For N=1:1:4 ANSWER(N)=K(N)

 채택된 답변

dpb
dpb 2015년 10월 20일

0 개 추천

No need; if you set the input vector prior to calling input and your user can enter an executable Matlab statement, input evaluates the input string with workspace variables in existence at the time. Simple example:
>> x=1:4; % execute before calling INPUT
>> res=input('Enter eqn of form f(x): ')
Enter eqn of form f(x): 2*x.^2
res =
2 8 18 32
>>

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Scope Variables and Generate Names에 대해 자세히 알아보기

질문:

2015년 10월 20일

답변:

dpb
2015년 10월 20일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by