Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Hello, any one help me, How can I write the expression and statements for these equations

1 回表示 (過去 30 日間)
Jose Louis
Jose Louis 2016 年 7 月 21 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
how can I write intervals in matlab
kt= G/G_o
for this condition:
G_d = G*(1-0.09*kt) for kt < 0.22
G_d = G*(0.9511-0.1604*kt+4.388*kt^2-16.638*kt^3+12.336*kt^4) for 0.22<=kt<=0.8
G_d = G*0.165 for k < 0.8

回答 (3 件)

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 7 月 21 日
編集済み: Azzi Abdelmalek 2016 年 7 月 21 日
G=1
kt=0:0.01:1
idx1=kt<0.22
idx2=kt>=0.22 & kt<0.8
idx3=kt>=0.8
G_d(idx1) = G*(1-0.09*kt(idx1))
G_d(idx2)= G*(0.9511-0.1604*kt(idx2)+4.388*kt(idx2).^2-16.638.*kt(idx2).^3+12.336.*kt(idx2).^4)
G_d(idx3) = G* 0.165

dpb
dpb 2016 年 7 月 21 日
Just as it's given, pretty much...
G_d = function(G,kt)
if kt<0.22
G_d = G*(1-0.09*kt);
elseif 0.22<=kt<=0.80
G_d = G*polyval([12.336 -16.638 4.388 -0.1604 0.9511],kt);
else
G_d = G*0.165;
end
This assumes the last "<" should've been ">" in the original problem statement; otherwise the conditions are inconsistent.
Also assumes kt is a single value, not a vector--in that case use logical addressing and array syntax.

Star Strider
Star Strider 2016 年 7 月 21 日
Another approach:
G = linspace(0, 1); % Create Data
G_o = 0.5; % Create Data
kt= G/G_o;
G_d1 = @(kt) G.*(1-0.09*kt);
G_d2 = @(kt) G.*(0.9511-0.1604*kt+4.388*kt.^2-16.638*kt.^3+12.336*kt.^4);
G_d3 = @(kt) G*0.165;
G_d = @(kt) G_d1(kt).*(kt < 0.22) + G_d2(kt).*((0.22 <= kt) & (kt <= 0.8)) + G_d3(kt).*(kt > 0.8);
figure(1)
plot(kt, G_d(kt))
grid

Community Treasure Hunt

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

Start Hunting!

Translated by