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 个评论
采纳的回答
22 个评论
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
更多回答(1 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- 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)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)