We get a sinewave form in matlab to calculate the voltage, but I need only the peak(rms or average) values of it. I need to find the voltage value as like in practicals using multimeter.
if it is a sine wave with no offset voltage, then the max and min functions will give you the same result (with the sign difference). When you have your signal in a vector x for example, just use max(x) to get the peak value.
Dear Vivekanandan Kandiannan! First question is: From where does your sinewave come ? If you have sinewave from any sensor or other real object (e.g. voltage from power grid 50/60Hz) , you have a lot disturbance too. In this case you can't use max or/and min functions, becouse you will get a large measurement errors. In this case you can calculate the RMS-value of signal (like Claudio Bruzzese wrote above), and next you must multiply RMS-value by factor equal sqrt(2) to obtain amplitude. Next question is: how many time do you have to measure amplitude of signal? One period of signal? Or more - it's simply. Or less - it's very dificult, but possible.
Dear Eligiusz Pawlowski And Sunil Manjani...! I have already mentioned in question its a voltage waveform (Sinewave), it is generated using PMSG in matlab.
So, if your voltage waveform (Sinewave) is generated using PMSG (in matlab or real generator), you must measure True R.M.S. (not peak or average value), I think. In power generation is important RMS voltage mainly because the power and energy depends on the RMS value of voltage. For this reason all the better voltmeters measure the RMS value. However, worse voltmeters measure the average value, but the display shows the RMS value too (they multiply the average value by the 1.111 - sine wave form factor).
You can calculate the RMS-value of signal like Claudio Bruzzese wrote above:
sqrt(sum(x.*x)/size(x)), but size(x) must be exactly equal to one period (or to integral multiple) of signal.
So, you need to know the period (or frequency) of the voltage signal too.