I am asked to write a function called standard_deviation_distance that takes as input a data vector [1xN] v and a number x [1x1], in that order. And I have code to call your function:
v = [10 12 14];
x = 7;
dist = standard_deviation_distance(v,x)% =-2.5

답변 (3개)

VBBV
VBBV 2022년 6월 5일
편집: VBBV 2022년 11월 10일

0 개 추천

v = [10 12 14];
x = ones(1,numel(v))*7;% length of x vector (weights) for each element and to be same as vector v
dist = standard_deviation_distance(v,x);
disp(['The standard deviation distance is ', num2str(dist)])
The standard deviation distance is 1.633
function y = standard_deviation_distance(v,x)
y = std(v,x);
end
Himanshu Desai
Himanshu Desai 2023년 5월 31일
편집: Himanshu Desai 2023년 5월 31일

0 개 추천

function y = standard_deviation_distance(v,x)
m = mean(v);
s = std(v);
y = (x-m)/s;
end
dist = -2.500
v = [10 12 14];
x = 7;
y = standard_deviation_distance(v,x)
Mark
Mark 2025년 8월 1일
편집: Walter Roberson 2025년 8월 1일

0 개 추천

v = [10 12 14];
x = ones(1, numel(v))*7;
dist = std(v,x)
dist = 1.6330
disp(['The standard deviation distance is ' num2str(dist)])
The standard deviation distance is 1.633

댓글 수: 3

Walter Roberson
Walter Roberson 2025년 8월 1일
I corrected the nume1() call to be numel()
Torsten
Torsten 2025년 8월 1일
편집: Torsten 2025년 8월 1일
I don't see a difference to @VBBV 's solution (except for "nume1" instead of "numel").
Maybe it was meant as "test test test".
Walter Roberson
Walter Roberson 2025년 8월 2일
@VBBV solution involved a function (as was required by the terms of the question)

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

카테고리

도움말 센터File Exchange에서 Polynomials에 대해 자세히 알아보기

질문:

2022년 6월 4일

댓글:

2025년 8월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by