MATLAB Answers

## Boxplot and Dimensions Arrays

Asked by Saira Ahmed

### Saira Ahmed (view profile)

on 22 Mar 2019
Latest activity Commented on by Saira Ahmed

### Saira Ahmed (view profile)

on 22 Mar 2019
Accepted Answer by the cyclist

### the cyclist (view profile)

%msf for sample size
msfs = [0.8929, 0.8547, 0.998, 0.9506, 0.9074, 0.9074];
%msf for population
msfp = [0.9836, 0.9685, 0.9097, 0.9027, 0.8278, 0.7551, 0.8929, 0.8547, 0.998, 0.9506, 0.9074, 0.9074, 1.0291, 1.032, 1.1996, 1.1181, 0.939, 0.752, 0.762, 0.0253, 0.933, 1.073, 0.644, 0.789];
%boxplot
figure(8)
group = [ ones(size(msfs)); 2*ones(size(msfp)) ];
boxplot([msfs; msfp], group)
set(gca, 'XTixkLabel', {'group', 'population'})
So, I'm trying to plot two vectors as a boxplot side by side and I've used the above code. But when input into MATLAB I get the following error message:
Dimensions of arrays being concatenated are not consistent.
And I wasn't sure how to fix it, I was wondering if anyone would be able to help?

#### 0 Comments

Sign in to comment.

## 1 Answer

### the cyclist (view profile)

Answer by the cyclist

### the cyclist (view profile)

on 22 Mar 2019
Accepted Answer

If you define your original arrays as column vectors, instead of row vectors, your code will work. Try this instead:
%msf for sample size
msfs = [0.8929, 0.8547, 0.998, 0.9506, 0.9074, 0.9074]';
%msf for population
msfp = [0.9836, 0.9685, 0.9097, 0.9027, 0.8278, 0.7551, 0.8929, 0.8547, 0.998, 0.9506, 0.9074, 0.9074, 1.0291, 1.032, 1.1996, 1.1181, 0.939, 0.752, 0.762, 0.0253, 0.933, 1.073, 0.644, 0.789]';

Saira Ahmed

### Saira Ahmed (view profile)

on 22 Mar 2019
That worked perfectly, thank you!

Sign in to comment.