Having the imped_calc function matters because now we can see the size and shape of the outputs.
- freq is a 1x21 vector.
- Z_e_tot and new_err are a 1x21 vectors
so the first input to fill() is [freq, flipud(freq)] which results in a 1x42 vector.
The second input is [Z_e_tot-new_err; flipud(Z_e_tot+new_err)] which results in a 2x21 vector.
This causes an unreported error,
Vectors must be the same length.
What you probably wanted to do is,
fill([freq, fliplr(freq)],[Z_e_tot-new_err,fliplr(Z_e_tot+new_err)],[.9 .9 .9], 'linestyle', 'none');
- The first two inputs are row vectors so you should horizontally concatenat them with ",". The 2nd input in your attempt used vertical concatenation with ";".
- Because they are row vectors you want to use fliplr, not flipud.