why i'm getting wrong answers from a simple equation

1 view (last 30 days)
>> 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

Answers (1)

Image Analyst
Image Analyst on 24 Jun 2021
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 Comment
firrou bouteflika
firrou bouteflika on 25 Jun 2021
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

Sign in to comment.

Products


Release

R2012a

Community Treasure Hunt

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

Start Hunting!