The plot was not out correctly

Hi, this is the codes i have for the problem but somehow the plot was not out correctly like the example output.
Please help me identify the mistake, please! TIA!
% TASK 1
Power = input('Enter the power rating of the lamp bulb [W]: ');
Time = input('Enter the time at which to calculate brightness [microseconds]: ');
I = 15 .* Power .* (1 - (1.40.*(exp(1)).^(-Time)) .* sin(1.43.*(Time) + pi./4));
fprintf('The brightness of the %d-Watt lamp will be %3.2f lumens at %d microseconds.\n', Power, I, Time);
% TASK 2
Surge = input('Enter the time the surge starts [microseconds]: ');
I = Brightness(Power, Time, Surge);
Surge = 10 .* Power .* exp(1).*(-1) .* sin(1.43./2);
fprintf('The brightness of the lamp will be %3.2f lumens at\n %d microseconds, after factoring in the power surge.\n', I, Time);
% TASK 3
Time = [0 : 0.01 : Time];
I = Brightness(Power, Time, Surge);
figure(1)
plot(Time, I, 'ro', 'LineWidth', 3);
title('Brightness of Lamp over Time');
xlabel('Time (t) [microseconds]');
ylabel('Brightness (I) [lumens]');
grid on

5 件のコメント

Steven Lord
Steven Lord 2020 年 9 月 22 日
We cannot run this code as you have not provided the Brightness function called in the sections for TASK 2 and TASK 3.
Samantha Pham
Samantha Pham 2020 年 9 月 22 日
i'm sorry, this is the brightness function
function I = Brightness(Power, Time, Surge)
I = 15*Power*( 1 - 1.4*exp(-Time).*sin( 1.43*Time + pi/4 ));
Is = 10*Power*exp(-1)*sin(1.43/2);
for i = 1:length(Time)
if Time(i) >= Surge
I(i) = I(i) + Is;
end
end
Adam Danz
Adam Danz 2020 年 9 月 22 日
編集済み: Adam Danz 2020 年 9 月 22 日
My outputs:
Your Brightness may not be doing whatever it does in the demo you're following. For starters, in your comment from previous question you mentioned that the inequality should be flipped. But there's more to it than that.
Alternatively, the images in the demo might be incorrect.
Samantha Pham
Samantha Pham 2020 年 9 月 22 日
so, this is the task that i did on Matlab but submit in Zybook. Mainscripts and the question i asked the first time is not on the same assignment. What i mean is, i write the brightness function in one page, and i write the whole script on another page. On that page, all the function are coded correctly by the professpor, so even if i did wrong on the brightness function, it doesnt really matter on the mainscript. I hope it makes sense.
Yes, i have same graphs as you, but somehow the sample output from professor gives different and i honestly dont know where.
Below is the whole assignment description. Thank you!
Samantha Pham
Samantha Pham 2020 年 9 月 22 日
Yes, maybe you're right. The sample outptut can be wrong

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangePerformance and Memory についてさらに検索

タグ

質問済み:

2020 年 9 月 22 日

コメント済み:

2020 年 9 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by