What is the code to call this function?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Arjun Krishnakumar
le 10 Juil 2020
Modifié(e) : Image Analyst
le 13 Juil 2022
The question asks for code to call this function below. What is it?
Please explain in detail the call for this function so that even a layman can understand it.
% Function to compute the area of a triangle.
% The area is one half the base width times the height.
function [area] = tri_area(b, h)
tri_area(b,h) = (1/2) * b * h ;
% area = tri_area(b, h); % Sample call.
end
0 commentaires
Réponse acceptée
Fangjun Jiang
le 10 Juil 2020
The function should be written like this and saved as tri_area.m
function [area] = tri_area(b,h)
area=1/2*(b)*(h);
end
Then in MATLAB Command Window, call the function like this
TheArea=tri_area(4,5)
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!