MATLAB: I just want to plot a freaking function : MATLAB is probably the most frustrating thing ever. I'm just trying to plot a freaking function and keep receiving this freaking thing: 

"Unbalanced or unexpected parenthesis or bracket."

This is my code:


    file charge.m
    function [q]=charge(t)
    G=66;
    R=24.7;
    L=2.74;
    C=0.000251;
    P1=-0.5*(R/L)*t;
    P2=t*sqrt(1/(L*C)-(R^2)/(4*L^2));
    q=G*exp(P1)*cos(P2);

and my main function 

main.m

    x=(0:0.001:1);
    y=charge(x.)
    plot(x,y)

What am I doing wrong? I keep searching and searching about how to do this and I'm still blank about it. 
Can someone help me?

