Filter löschen
Filter löschen

Subtracting two matrices yields a scalar in MATLAB

1 Ansicht (letzte 30 Tage)
Nourhan
Nourhan am 2 Mär. 2014
Bearbeitet: Paul am 2 Mär. 2014
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

Akzeptierte Antwort

Paul
Paul am 2 Mär. 2014
Bearbeitet: Paul am 2 Mär. 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.

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices 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!

Translated by