Zero pad using piecewise.
Mostrar comentarios más antiguos
Hello,
I need help zero padding a function.
This the code for the function:
Vr = (eps*((r0./r).^12));
Va = (-eps*(2*(r0./r).^6));
V = Vr+Va
I need to zero pad it so that all values of V that are above 0 are set to 0.
So in written forms I need this:
{0, V>0}
V=
{V, V<0}
I tried this so far:
V = piecewise(Vr+Va>0,0, Vr+Va<0,Vr+Va);
but I keep getting this error:
Incorrect number or types of inputs or outputs for function piecewise.
Error in Project_2 (line 22)
V = piecewise(Vr+Va>0,0, Vr+Va<0,Vr+Va);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 31 de Oct. de 2024
0 votos
piecewise() requires that the first input be a symbolic expression.
Your Vr+Va is likely numeric.
Categorías
Más información sobre Error Detection and Correction en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!