필터 지우기
필터 지우기

How can I define handle function in a loop with predefined coefficient?

조회 수: 4 (최근 30일)
Ashkan Rigi
Ashkan Rigi 2021년 10월 27일
댓글: Rik 2021년 10월 27일
here is the some lines of code:
a=[1 2 3];
b=[4 5 6]
for i=1:length(a)
s_i{i}=@ (x) a(i)*x^2+b(i)*x;
end
I would like to take the listed below by the codes:
s(1)=1*x^2+4*x
s(2)=2*x^2+5*x
s(3)=3*x^2+6*x
  댓글 수: 1
Rik
Rik 2021년 10월 27일
How doesn't this do what you want?
There is just a small syntax difference: you need to use curly braces when indexing into s.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by