Vous suivez désormais cette question
- Les mises à jour seront visibles dans votre flux de contenu suivi.
- Selon vos préférences en matière de communication il est possible que vous receviez des e-mails.
Plot multiple graph after solving
I have following two equations -
f1 = -2*g*t.^3/((1 - y).^(1-2*g)) + 2*g*(3 - t.^2)^2./((2 - t).*y.^(1-2*g)) + (8*g*t)./(y.^(1-2*g)) - 2*g*(3 - 2*t).^2./((2 - t).*(1 - y).^(1-2*g)); f2 = t - (((y.^(2*g))*(2/3) - (((1-y).^(2*g)).*((3 - 2*t)./(3*(2-t)))))./((y.^(2*g)).*(((3-t.^2))./(3*(2-t))) - ((1-y).^(2*g)).*(t/3)));
For every g in the range (0,0.114), solving the two equations above give two solution - y with t=1 and y with a t between 0.5 and 1. (it also give solution with negative y and t less than 0.5, I am not interested in them). To give a sense, for g=0.11 I get following solution - t=1 ^ y=0.85536 t=0.9873 ^ y=0.85530.
I want Matlab to plot two graph (on same plot) with g on x axis and y values in y axis. One graph should have y values for t=1 and one graph should have y values for t in range 0.5 to 1 (below 1).
Since I have done numerical simulation with random values, I know graph should look the following (attached rough sketch)
I don't know how to ask Matlab to pick the specific ans and then plot them. Shall I create a loop?
5 commentaires
Réponse acceptée
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1464982/image.png)
22 commentaires
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1469801/image.png)
Thank you @Torsten. One last question. If I have to go one step ahead and want Matlab to substitute the pair of solution [that I got by solving f1 and f2 for each g in range 0.01 to 0.12) with (t=1 with associated y) and (t<1 with associated y) into following function -
f4 = (((3-t^2)^2)*(y^(2 g))+ ((3 - 2 t)^2)*(1 - k)^(2 g))/(18 (2 - t)) + (1/18) (4 t (k^(2 g)) + t^3 ((1 - k)^(2 g)))
And generate me two curves - one with solution of above function when t=1 and other when t<1 against g on x axis. How can I do it.
Help @Torsten
f4 is not 0. f4 is just a function of t and y and I want the value of this function at Solution of t and y. f4 is an objective function.
f4 = (((3-t^2)^2)*(y^(2*g))+ ((3 - 2*t)^2)*(1 - k)^(2*g))/(18*(2 - t)) + (1/18)*(4*t*(k^(2*g)) + (t^3)*((1 - k)^(2*g)))
I want to plot the value of objective function against g - two separate lines: one at t=1, other at t<1. Please help @Torsten
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1471476/image.png)
Why I am getting this error -
Error using arrayfun All of the input arguments must be of the same size and shape. Previous inputs had size 118 in dimension 2. Input #3 has size 111
And I am really sorry - there is no k in f4, it is y. It is my typo.
f4 = (((3-t.^2).^2).*(y.^(2*g))+ ((3 - 2*t).^2).*(1 - y).^(2*g))./(18*(2 - t)) + (1/18)*(4*t.*(y.^(2*g)) + (t.^3).*((1 - y).^(2*g)));
Please help @Torsten
Plus de réponses (1)
Voir également
Catégories
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Une erreur s'est produite
Impossible de terminer l’action en raison de modifications de la page. Rechargez la page pour voir sa mise à jour.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asie-Pacifique
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)