Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Simple for loop question.

1 vue (au cours des 30 derniers jours)
Jake
Jake le 7 Déc 2012
Clôturé : MATLAB Answer Bot le 20 Août 2021
I am wanting to write a for loop for 2 differential equations.
For 0<x<5 dadb = (2*x)
For 5<x<10 dadb = (3*x)
How would I code this?
Cheers
  3 commentaires
Jake
Jake le 9 Déc 2012
Modifié(e) : Walter Roberson le 9 Déc 2012
Sorry i will re-write that...
For 0<x<5 dz/dx = (2*x)
For 5<x<10 dz/dx = (3*x)
Jan
Jan le 9 Déc 2012
Are you sure that you mean a FOR-loop? Look at "doc for" and "help for", if this really matches your needs.

Réponses (1)

Rick Rosson
Rick Rosson le 9 Déc 2012
Modifié(e) : Rick Rosson le 9 Déc 2012
dx = 0.01;
x = (0:dx:10-dx)';
idx = (x < 5);
C = ...
D = ...
z = ( C + x.^2 / 2 ) .* idx + ( D + x.^3 / 3 ) .* ( 1 - idx ) ;
You will need to specify values for the constant C and D based on the initial value of z and the continuity condition at x = 5.

Cette question est clôturée.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by