Undefined function or variable 'x'.

조회 수: 3 (최근 30일)
Kati Roberts
Kati Roberts 2016년 11월 24일
답변: Walter Roberson 2016년 11월 24일
This is a function that conducts t-tests.
x=[197, 161, 144, 162, 185, 154, 136, 130]
% y=[204, 182, 140, 178, 183, 163, 156, 143]';
%
% Usage:
% [CI, tcrit, H, Pval, tstat, df] = myttestfcn(x, y, testtype, side, alpha)
% x = vector of operations
% mu0 = hypothesized mean
%
% testtype = 0 if Welch’s t-test
% = 1 if Pooled t-test
% = 2 if Paired t-test
%
% side = 0 if two-sided test
% = 1 if left-sided test
% = 2 if right-sided test
%
% alpha = the level of the test a number on interval (0,1)
% Confidence level = 1 - alpha
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [CI, tcrit, H, df] = myttestfcn(x, y, testtype, side, alpha)

답변 (1개)

Walter Roberson
Walter Roberson 2016년 11월 24일
Your line
x=[197, 161, 144, 162, 185, 154, 136, 130]
should be commented out. The code from "Usage:" on down should be saved in myttestfcn.m . To invoke the function you will need to go to the command line and invoke it there, such as
x=[197, 161, 144, 162, 185, 154, 136, 130];
y=[204, 182, 140, 178, 183, 163, 156, 143]';
[ci, crit, h, df] = myttestfcn(x, y, 2, 1, 0.5)

카테고리

Help CenterFile Exchange에서 String Parsing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by