Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
I am trying to make a mesh plot with a contour plot beneath it where the decayTime goes from 0.5-10, and time goes from 0 to 15. My formula for the z variable is included below, and I know how to plot, just not where my error is. THANKS!!
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
%%Declarations
phaseShift = 0;
oscillationFreq = 2; % rad/s
decayTime = linspace(.5,10); % seconds
t = linspace(0,15); % seconds
%%Calculations
[xG,yG] = meshgrid(t,decayTime);
z = exp((-1*xG)/yG)*sin((oscillationFreq*xG)+phaseShift);
%%Plotting
meshc(xG,yG,z)
2 commentaires
Stephen23
le 21 Sep 2017
@Snooping Poppet: it is not appreciated when you edit away the text of your question. Imagine if everyone did that, then this entire forum would be useless for anyone else as it would only consist of thousands of threads all reading "This post was taken down". Would you find that useful?
By deleting your question you unilaterally decided that Star Strider's volunteered time helping you shall not be useful to anyone else. Does Star Strider get a say in this decision? Do you think this is why we volunteers come here and write our advice and comments?
If you want a consulting service then you will find plenty of them on them internet. This is a community forum with answers provided by volunteers.
Réponses (1)
Star Strider
le 29 Nov 2016
Your error is in not doing element-wise operations in your ‘z’ calculation.
This works:
%%Declarations
phaseShift = 0;
oscillationFreq = 2; % rad/s
decayTime = linspace(.5,10); % seconds
t = linspace(0,15); % seconds
%%Calculations
[xG,yG] = meshgrid(t,decayTime);
z = exp((-1*xG)./yG).*sin((oscillationFreq*xG)+phaseShift);
%%Plotting
meshc(xG,yG,z)
grid on
Note the ‘.’ preceding the multiplication and division operators. See the documentation on Array vs. Matrix Operations for details.
1 commentaire
Cette question est clôturée.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!