필터 지우기
필터 지우기

Subtracting two matrices yields a scalar in MATLAB

조회 수: 1 (최근 30일)
Nourhan
Nourhan 2014년 3월 2일
편집: Paul 2014년 3월 2일
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

채택된 답변

Paul
Paul 2014년 3월 2일
편집: Paul 2014년 3월 2일
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개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by