why i'm getting wrong answers from a simple equation

1 次查看(过去 30 天)
>> t = [2993;3975.9;5063;6150;6919;8192.7;8862;10240.9;11488;12409.63;13545]
>> f = @(t) (2.2/9500).*((t/9500).^1.2).*exp(-((t/9500).^2.2))
>> g = @(t) 1-exp(-((t/9500).^2.2))
>> f(t)-g(t)
>> ans =
-0.0869 0.32398874
-0.1561 0.39063829
-0.2510 0.31369048
-0.3581 0.31787694
-0.4370 when answers should be ....
-0.5654 ...
-0.6286 ..
-0.7437
-0.8268
-0.8748
-0.9194

回答(1 个)

Image Analyst
Image Analyst 2021-6-24
My guess is that you've probably misplaced some parentheses. Check them very carefully. And you don't need the @(t) - you can simply do
t = [2993;3975.9;5063;6150;6919;8192.7;8862;10240.9;11488;12409.63;13545]
f = (2.2/9500).* ((t/9500).^1.2).*exp(-((t/9500).^2.2))
g = 1 - exp(-((t/8900).^2.2))
results = f - g
% Plot things below.
plot(t, f, 'b.-', 'LineWidth', 2, 'MarkerSize', 20);
hold on;
plot(t, g, 'r.-', 'LineWidth', 2, 'MarkerSize', 20);
grid on;
legend('f', 'g', 'Location', 'north');
  1 个评论
firrou bouteflika
firrou bouteflika 2021-6-25
thank you but i'm soryy i made a stupid mistake the f equation results should be arranged from min to max after that we do results = f - g please help me do that
and also a small mistake that doesnt matter g = 1 - exp(-((t/8900).^2.2)) 8900 should be 9500

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品


版本

R2012a

Community Treasure Hunt

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

Start Hunting!

Translated by