필터 지우기
필터 지우기

how can I pass an equation as input parameter to function

조회 수: 9 (최근 30일)
Eman Ahmed Elsayed
Eman Ahmed Elsayed 2011년 5월 31일
댓글: Ayesha Khan 2023년 3월 11일
I write s function which take two parameter the first is an equation and the second is an integer number and I want to substitute with this number in the equation and return the result.
function result=sub(a,c)
%UNTITLED3 Summary of this function goes here
% Detailed explanation goes here
result=subs(a,c);
end
when I test it on command window I write
>> result=sub(2*x,1)
I get an error
??? Undefined function or variable 'x'.

답변 (1개)

Eman Ahmed Elsayed
Eman Ahmed Elsayed 2011년 5월 31일
I solved my problem
I wrote the function like the following
>> f=@(x) 2*x + 1
and then passed it to the function

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by