What does it mean to "% extract t and h(t) for time range 5.0<=t<=12.0" when "h=4.0+6.0*t*10^-0.5-(4*10^-0.25)*cos(0.75*pi*t)"?; when
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Im not really sure what this means at all...
0 Kommentare
Antworten (2)
Walter Roberson
am 29 Sep. 2022
One way:
Loop over the indices of the vector of t. At each point, make the "current" t equal to the t vector indexed at the current index value. Test the current t to see if it is in the desired range. If it is, then save the current t and save h indexed at the current index.
At the end, the saved t will be only the t in the desired range, and the saved h will be the corresponding h elements.
This is not what I would actually do myself: I would use logical indexing.
1 Kommentar
Walter Roberson
am 29 Sep. 2022
What the phrase means is that you need to store all the t values that are in range into a variable, and you need to store the locations in h at the corresponding offset into a variable.
Image Analyst
am 29 Sep. 2022
t is defined over some range, like 0 to 50 or whatever. Then the comment says they only want h values for t that is in the range 5-12. So you'd create a mask
t = linspace(0, 50, 51) % However you want it.
h = 4.0 + 6.0 * t * 10^(-0.5) - 4 * 10^(-0.25) * cos(0.75 * pi * t)
% Extract t and h(t) for time range 5.0<=t<=12.0"
% First make a mask
mask = (t >= 5) & (t <= 12)
t2 = t(mask)
h2 = h(mask)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!