Value to get back to initial
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello!!
Shown in the image, I have a exponential decay of fluid due to dialysis. I want to stop the dialysis at 75mg/Liter (shown at the intersection at the red line and blue line) and want to see how long it takes from that point to go back up to 150mg/Liter. How can i do that?![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/203522/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/203522/image.png)
2 commentaires
Mark Sherstan
le 10 Fév 2019
To clarify you want to find the intersection point at y = 75 and y = 150 and find the time between those two points?
Réponse acceptée
Adam Danz
le 11 Fév 2019
Modifié(e) : Adam Danz
le 11 Fév 2019
This solution finds the time window that starts and ends when dialysis is at 75 and 150, respectively. I created fake data to work with. Then you can define the dialysis window. 'Duration' is the duration of the window along the x axis that starts and ends according to the dialysis window along the y axis. Lastly, a plot is produced to show the window for confirmation.
% Create fake data to work with
time = 0 : .1 : 50;
x = linspace(10.5, -2, length(time));
dialysis = exp(x/2);
% define dialysis window
window = [75, 150];
% Find closest index to the dialysis window
% Assumes 'dialysis' is a row vector. Otherwise, remove transposes.
[~, minIdx] = min(abs([dialysis', dialysis'] - window));
% Calculate time between the dialysis window
duration = time(minIdx(1)) - time(minIdx(2));
% Verify by plotting results
figure
plot(time, dialysis);
hold on
plot(time([1,1;end,end]), dialysis([minIdx; minIdx]), 'm-') %dialysis window
plot(time([minIdx; minIdx]), dialysis([minIdx', minIdx']), 'm-') %time window
title(sprintf('Fake Data; time window = %.2f', duration))
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/203541/image.jpeg)
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!