You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
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 Comments
Accepted Answer
22 Comments
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
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
More Answers (1)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- 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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)