Hey,
I'm trying to do an unpaired t-test but I'm getting a stupid error. This is my code: For some reason the second numbers in my vectors are causing an error I think it is a small mistake but I can't find it
Someone an idea? Thank you!
x = 40.62154549 40.75664465 36.73637154 36.83770617 43.3711409 43.5308889 42.232434 41.9015272;
y = 39.7716099 36.2757949 36.522279 31.2306774 31.4157967 32.9799975 32.7431478;
h = ttest2(x,y);
h = ttest2(x,y,Name,Value);
[h,p] = ttest2(x,y,'Vartype','unequal');
[h,p,ci,stats] = ttest2(x,y);

3 commentaires

Dries Boon
Dries Boon le 18 Avr 2018
This is the error by the way: Error: File: test.m Line: 1 Column: 17 Unexpected MATLAB expression.
Dennis
Dennis le 18 Avr 2018
31,4157967 is , seperated
Dries Boon
Dries Boon le 18 Avr 2018
I fix it, but still the two second numbers of x and y are causing an error

Connectez-vous pour commenter.

 Réponse acceptée

Stephen23
Stephen23 le 18 Avr 2018
Modifié(e) : Stephen23 le 18 Avr 2018

0 votes

Simply pasting individual numbers does not define a vector: they need to be specified within square brackets. Currently those values are not joined into one vector using square brackets and so MATLAB interprets the first number as a scalar to be allocated to x, and then the trailing numbers are simply a syntax error.

To define a vector of numbers use [], e.g.:

x = [40.62154549, 40.75664465, 36.73637154, 36.83770617, ... ]

How to define vectors/matrices is explained in the introductory tutorials, which are highly recommended for all beginners:

https://www.mathworks.com/help/matlab/getting-started-with-matlab.html

Plus de réponses (0)

Catégories

En savoir plus sur Function Creation dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by