MATLAB: I want to plot a function for different values of time

MATLABplot

This is a function in 2 variable (x,t)
f = (699729515992263*exp(-(3555899736243218994140625*t)/9007199254740992)*cos(20000000*pi*x))/144115188075855872 – (8478402047166467*exp(-(3555899736243218994140625*t)/36028797018963968)*cos(10000000*pi*x))/1152921504606846976 + (4049874448795339*exp(-(3555899736243218994140625*t)/2251799813685248)*cos(40000000*pi*x))/1152921504606846976 – (4758684662903855*exp(-(32003097626188970947265625*t)/36028797018963968)*cos(30000000*pi*x))/1152921504606846976 – (7369322330077077*exp(-(44448746703040240478515625*t)/18014398509481984)*cos(50000000*pi*x))/2305843009213693952 + 1/100 ;
I want to plot the function f(x) for different values of t , for example for x = (0, 1e-6) and for 10 values of t like { 0, 0.001, 0.002, … 0.01} .
All together in 1 plot. So there may be 10 plots in a single figure.

Best Answer

f = @(x,t) (699729515992263*exp(-(3555899736243218994140625*t)/9007199254740992)*cos(20000000*pi*x))/144115188075855872 - (8478402047166467*exp(-(3555899736243218994140625*t)/36028797018963968)*cos(10000000*pi*x))/1152921504606846976 + (4049874448795339*exp(-(3555899736243218994140625*t)/2251799813685248)*cos(40000000*pi*x))/1152921504606846976 - (4758684662903855*exp(-(32003097626188970947265625*t)/36028797018963968)*cos(30000000*pi*x))/1152921504606846976 - (7369322330077077*exp(-(44448746703040240478515625*t)/18014398509481984)*cos(50000000*pi*x))/2305843009213693952 + 1/100 ;
t = linspace(0,0.01,10);
figure
hold on
plot(t,f(0,t))
plot(t,f(1.e6,t))
Related Question