Transposing matrix of elements added by for loop

2 次查看(过去 30 天)
I am creating a matrix with 38 unique entries. My for loop is creating a 1x38 matrix but I need it to be 38x1 for the operation I'm trying to perform. I tried using transpose but that did not work. How would I transpose this matrix so that I get each element added as a new row instead of a column? This is occuring on the Sol.RHS matrix
for i=1:inds.numinds
for j=1:inds.ind_dat(i).nconn
%
% gather the properties on both sides
%
jind=inds.ind_dat(i).conn_array(j).ind;
jsign=inds.ind_dat(i).conn_array(j).sign;
%
% indices for implicit contribution
%
ivmm=inds.numind*ind_scale_eq + (jind - 1) + 1;
%
% add in implicit and explicit terms - vapor
%
Sol.mat(ivmm,ivmm)=Sol.mat(ivmm,ivmm)+juns.jun_dat(jind).a*jsign/inds.ind_dat(i).volume;
Sol.RHS(ivmm)=transpose(Sol.RHS(ivmm)+juns.jun_dat(jind).a*jsign*inds.ind_dat(jind).vv/inds.ind_dat(i).volume);
end
end
  2 个评论
Matt J
Matt J 2021-6-28
I tried using transpose but that did not work
It doesn't seem possible that that would not work.
DGM
DGM 2021-6-28
How exactly did it not work? Since there really isn't any information here about the size of any of these variables, I have no idea what would happen. All anyone can go on is your assertion that one of them is 1x38 -- something that any troubleshooting should question if array size/orientation is not meeting expectations. You might want to provide enough data or pseudo-data such that your code constitutes a minimal working example of your problem.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by