Borrar filtros
Borrar filtros

Matlab If Else Statement

2 visualizaciones (últimos 30 días)
Joseph DeMaria
Joseph DeMaria el 2 de Nov. de 2020
The prompt of the question I have to do is: " The value of y is defined in terms of x by y=ln(0.5-x), write a function myfun(x) that takes some value x and does the following:
If x is greater or equal to 0.5 the function should caluculate y by using the negative value of that x and assign the result to z
If the value of x smaller than 0.5 the function should return the value z where z is calculated as the following
z=y^n
where n is (x+(100*x)) rounded to the nearest integer.
In my code, under a new scipt I created the function saved as "myfunx" as follows;
function myfun(x)
if x>=0.5
y=ln(0.5-(-x))
z=y^n
else
y=ln(0.5-x)
z=y^n
end
and in the command window when I test it with such value as x=1 and call the funciton myfunx, and it reads error and claims
"Not enough input arguments.
Error in myfunx (line2)
if x>=0.5
However I do not know what Im doing wrong or how I could fix this, any tips or ideas that could help me solve this would be appreciated thank you!

Respuestas (0)

Categorías

Más información sobre Configure Simulation Conditions 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