Trying to get a table output when inputs are arrays for norminv function

I have input data (for weight) in 7 samples for a mean, std error of the mean, and number of participants in each sample. I data for 7 conditions and I would like to produce data at the following intervals on the image under p.
Each input is a 7*1 double, apart from the propbability intervals (9 parts) . I would like to produce new actual weight values at each probability.
How can I use the normiv function to take data from one of my samples ( input of p,mean,std) and produce 9 weight values for each sample?
Using this code I get the following meassage "Error using norminv (line 63)
Non-scalar arguments must match in size."
Many Thanks
Dylan

7 Comments

Then the easiest way to localize the problem is to insert the lines
size(p)
size(mean)
size(std)
in front of the call to norminv.
If not all three sizes are equal, you will have to change something in your code to make them equal.
The probability size is 9*1 and the others are 7*1, however it works with the same 9*1 probability and the std and mean being just single values, producing a 9*1 output of the weights at each probability for that mean and std.
however it works with the same 9*1 probability and the std and mean being just single values, producing a 9*1 output of the weights at each probability for that mean and std.
Sure. In this case, it is assumed that you want to calculate norminv(p) for a fixed value of mean and variance for all the probability values. If you specify vectors of the same length for p, mu and sigma, then MATLAB returns a vector x where x(i) is norminv(p(i),mu(i),sigma(i)). If you specify vectors for p, mu and sigma with different lengths, MATLAB is baffled about what you want (like me).
Maybe you want something like this:
for i=1:numel(mu)
x(:,i) = norminv(p,mu(i),sigma(i));
end
Ah I think I understand, if it helps I might be able to explain what I wanted better.
Input, 7 different conditions (with a mean and std each)
Ideal Output 9 weights (1 for each probability) for each condition so 9*7 outputs
Does that help? Thanks
This is the answer given above ; x is 9x7.
Thank you very much, that is perfect, how can I accept your answer?

Sign in to comment.

 Accepted Answer

Maybe you want something like this:
for i=1:numel(mu)
x(:,i) = norminv(p,mu(i),sigma(i));
end

More Answers (0)

Products

Release

R2021a

Asked:

on 16 Apr 2022

Commented:

on 17 Apr 2022

Community Treasure Hunt

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

Start Hunting!