append new row in for loop to create matrix
1 次查看(过去 30 天)
显示 更早的评论
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
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!