Subtracting two matrices yields a scalar in MATLAB
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Dear all,
I have the following code :
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:length(QRS_onset)
T_wave_duration_in_sec(i)=ST_Interval_in_sec(i)-ST_Segment_in_sec(i);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Both the ST interval and ST segment are matrices. However, the result of T wave duration is scalar. Why is this?
Thanks in advance for the help
0 commentaires
Réponse acceptée
Paul
le 2 Mar 2014
Modifié(e) : Paul
le 2 Mar 2014
Are you trying to only substract some of the elements? Else you can simply do: A-B. Also i guess you mean the result is a vector instead of a matrix. That is because of the way you fill it. You use linear indices for ST_Interval_in_sec and since T_wave_duration_in_sec is not predefined it just makes a vector. See: http://www.mathworks.nl/company/newsletters/articles/matrix-indexing-in-matlab.html
You can fix this by doing this before the loop: T_wave_duration_in_sec = zeros(rows,cols);
rows and cols should be the size of the output matrix.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical 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!