Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

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 visualizzazione (ultimi 30 giorni)
%%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 Commenti
Stephen23
Stephen23 il 21 Set 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.

Risposte (1)

Star Strider
Star Strider il 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.

Questa domanda è chiusa.

Tag

Non è stata ancora inserito alcun tag.

Community Treasure Hunt

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

Start Hunting!

Translated by