Question 2 (25 points): Build a function f(t) that outputs according to the following conditions: f(t) = ln(t + 1) = {ince 0; t≤0 ;0 % Initialize f to 0 for all t f=zeros(size(t)); for i=1:length(t) f(i) = piecefcn(t(i)); end % Plot function here % Piecewise function here function [f]=piecefcn(t) % Conditional statement here end

Operations Research : Applications and Algorithms
4th Edition
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Wayne L. Winston
Chapter16: Probabilistic Inventory Models
Section16.3: The News Vendor Problem: Discrete Demand
Problem 9P
icon
Related questions
Question

do the following code on matlab with the given and specified format

Question 2 (25 points):
Build a function f(t) that outputs according to the following conditions:
f(t) = ln(t + 1)
= {ince
0; t≤0
;0<t<3.4725
Зе-0.2t
; Otherwise
Update the following code that has a template for the function and call it in the main to plot
the f(t).
% Main code
clc;
clear;
% Define t from -1 to 5 with a step size of 0.01
<Your Code here >
% Initialize f to 0 for all t
f=zeros(size(t));
for i=1:length(t)
f(i) = piecefcn(t(i));
end
% Plot function here
<Your Code here >
% Piecewise function here
function [f]=piecefcn(t)
% Conditional statement here
<Your Code here >
end
Transcribed Image Text:Question 2 (25 points): Build a function f(t) that outputs according to the following conditions: f(t) = ln(t + 1) = {ince 0; t≤0 ;0<t<3.4725 Зе-0.2t ; Otherwise Update the following code that has a template for the function and call it in the main to plot the f(t). % Main code clc; clear; % Define t from -1 to 5 with a step size of 0.01 <Your Code here > % Initialize f to 0 for all t f=zeros(size(t)); for i=1:length(t) f(i) = piecefcn(t(i)); end % Plot function here <Your Code here > % Piecewise function here function [f]=piecefcn(t) % Conditional statement here <Your Code here > end
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
Recommended textbooks for you
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage