writing and plotting function with multiple conditions
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mohammadreza A
el 3 de En. de 2021
Editada: Alan Stevens
el 3 de En. de 2021
Imagine I have a function like this:
How can I write this function in matlab and plot it between 0 and 1? How can I also compute of this function?
I want to have something like f=@(x) my_func
0 comentarios
Respuesta aceptada
Alan Stevens
el 3 de En. de 2021
Editada: Alan Stevens
el 3 de En. de 2021
One possibility:
f = @(x) 9/5*x*(0<=x & x<1/2)+9/5*(1-x)*(1/2<=x & x<=1);
e.g.
f(0.1)
ans =
0.1800
>> f(0.75)
ans =
0.4500
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Annotations 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!