필터 지우기
필터 지우기

append new row in for loop to create matrix

조회 수: 2 (최근 30일)
Khairul Nur
Khairul Nur 2019년 11월 16일
댓글: Khairul Nur 2019년 11월 18일
hi, i want to append a row to creating a 40x4 matrix. Here is my code.
for j= 1:row % row=4
for n=1:noofrow %noofrow=40
result1= sum((mnew(j,:)- MM(n,:)).^2)
mat(:,j) = result1
end
end
the loop is execute well..and each loop will have mat value containing 1x4. How to create a matrix that containing each loop result. the end result will have new matrix 40x4. I try to use reshape(result1,40,4); but error since not tally with matrix size inside the loop (1x4). Please give some solution or suggestion. TQIA
  댓글 수: 3
Khairul Nur
Khairul Nur 2019년 11월 18일
yes, its come from the same code, but i already fix the previous code. Previous q more to the loop things.
In this question, i try to store the result in matrix. The above is the correct code. every loop it will produce mat. How to store mat in matrix. Anyway, thanks for your time.
Khairul Nur
Khairul Nur 2019년 11월 18일
for j= 1:row %4 kali mnew
for n=1:noofrow %loop 40 kali
result1= sum((mnew(j,:)- MM(n,:)).^2)
% mat(:,j) = result1
% mat2(n,:) = mat(:,j)
end
mmat(:,j) = mat2 % i did this !
mmat do the matrix. I found it. I am new n noob. Its take times for me. But i never quit!

댓글을 달려면 로그인하십시오.

답변 (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