Write an user-defined function to calculate the mean value and the maximum value of the following vector. Write another function to count how many ‘0’s the vector has x = [0, 103, 0, 105, 104, 0, 99, 100, 0, 102, 0, 107, 105] need help with this one also. it jsut userdefined functions that i don't get.

 채택된 답변

madhan ravi
madhan ravi 2018년 11월 16일

1 개 추천

x = [0, 103, 0, 105, 104, 0, 99, 100, 0, 102, 0, 107, 105]
RESULT=noofzeros(x) %function calling
[MEAN,MAX] = meanmax(x) %function calling
function result = noofzeros(x) %function definition
result = numel(x(x==0));
end
function [MEAN,MAX] = meanmax(x) %functin definition
MEAN = mean(x);
MAX = max(x);
end

댓글 수: 2

Terrell Curley
Terrell Curley 2018년 11월 16일
Thank you! was worried about this all day!
madhan ravi
madhan ravi 2018년 11월 16일
Anytime :)

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

KSSV
KSSV 2018년 11월 16일
편집: KSSV 2018년 11월 16일

0 개 추천

x = [0, 103, 0, 105, 104, 0, 99, 100, 0, 102, 0, 107, 105] ;
iwant = nnz(x==0)

질문:

2018년 11월 16일

댓글:

2018년 11월 16일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by