Trying to get a table output when inputs are arrays for norminv function
Show older comments
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.
Dylan Clark
on 17 Apr 2022
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
Dylan Clark
on 17 Apr 2022
Dylan Clark
on 17 Apr 2022
Torsten
on 17 Apr 2022
I moved my comment to an answer.
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!