Variables not displaying in workspace
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
In MATLAB 2018a version, I am filling in a 3x100 vector that I initialize at the beginning. None of the variables (v,j,heartrate) are showing in the workspace, but am using heartrate(1,:) to plot a graph and that is working successfully. I do not know how I am able to plot this graph if the heartrate matrix is not the workspace. I have posted parts of my code below (it is long, so I have included the necessary parts only). I have tried putting the zeros vector inside and outside the function already. Thank you for your help!
function bpm = MyHeartRateOG(currentheart, restingheart, condition)
heartrate = zeros(3,100);
v = [1:100]
j = [0.8 .95 0.7 0.85 0.85 0.925 0.7 0.85 0.8 0.95 0.85 0.925 0.7 0.85 0.8 0.95 0.85 0.925; 0.8 0.95 0.7 0.85 0.85 0.925 0.07 0.85 0.8 0.95 0.85 0925 0.7 0.85 0.8 0.95 0.33 0.66 ; 0.8 0.95 0.7 0.85 0.85 0.925 0.7 0.85 0.8 0.95 0.85 0.925 0.7 0.85 0.8 0.95 0.33 0.66];%matrix of probabilities
for k = 1:3
heartrate(k,1)= restingheart;
heartrate(k,2)= currentheart;
for i = 2:100
N = rand();
if condition ==1 %Normal Heart
if heartrate(k,i)< heartrate (k,i-1)
(more if statements in between that should fill in the heartrate vector)
plot(v,heartrate(1,:)); %Graph which is being successfully plotted using heartrate matrix
1 commentaire
Stephen23
le 18 Déc 2018
"None of the variables (v,j,heartrate) are showing in the workspace..."
But they exist inside the function workspace, which is independent of the base workspace:
To view variables in function's workspace use the debugging tools:
Réponses (1)
James Tursa
le 18 Déc 2018
Modifié(e) : James Tursa
le 18 Déc 2018
The variables v, j, and heartrate are local variables and only exist inside the function MyHeartRateOG workspace. Once this function returns to the caller, those variables don't exist in the caller workspace. If you want to see them, you will need to pause the code inside the function (click at the left of the line in the editor and it will pause on that line), or you can put these variables in the output argument list to see them in the caller workspace. E.g.,
function [bpm,v,j,heartrate] = MyHeartRateOG(currentheart, restingheart, condition)
0 commentaires
Voir également
Catégories
En savoir plus sur Creating, Deleting, and Querying Graphics Objects 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!