Writing a script that mirrors the abs function? I'm doing something wrong but not sure what
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Here is the question:
The abs function finds the absolute value of a number or numbers in a matrix.
Using only relational operators and no built-in MATLAB functions, write a script
that recreates the abs function.
Here is what I did:
prompt='Enter a number';
x=input(x)
if x>0
disp(x)
elseif x<0
disp(x*(-1))
end
Help? Please?
1 Kommentar
the cyclist
am 20 Okt. 2019
In the future, it's best to include the complete error message that you are seeing. Also, I used the CODE icon to format your code.
Antworten (1)
the cyclist
am 20 Okt. 2019
I think you meant
x=input(prompt)
Siehe auch
Kategorien
Mehr zu Debugging and Analysis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!