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
1 回表示 (過去 30 日間)
古いコメントを表示
Im not really sure what this means at all...
0 件のコメント
回答 (2 件)
Walter Roberson
2022 年 9 月 29 日
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 件のコメント
Walter Roberson
2022 年 9 月 29 日
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
2022 年 9 月 29 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Author Block Masks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!