I want to plot a function for different values of time

3 Ansichten (letzte 30 Tage)
Anshuman S
Anshuman S am 3 Mär. 2020
Beantwortet: the cyclist am 3 Mär. 2020
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.
  2 Kommentare
darova
darova am 3 Mär. 2020
Did you try to use plot?
What problems do you have?
Anshuman S
Anshuman S am 3 Mär. 2020
I don't know how to use plot for 2 variables! Do i need to use a for loop?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

the cyclist
the cyclist am 3 Mär. 2020
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))

Weitere Antworten (1)

David Hill
David Hill am 3 Mär. 2020
Not sure what you are after, but you can try this:
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 ;
[x,t]=meshgrid(linspace(0,1e-6,10),linspace(0,.01,10));
plot3(x,t,f(x,t));
surf(x,t,f(x,t));

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by