Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
Ashkan Rigi
Ashkan Rigi el 27 de Oct. de 2021
Comentada: Rik el 27 de Oct. de 2021
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 comentario
Rik
Rik el 27 de Oct. de 2021
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.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by