Write 3x1 matrix to excel file in for loop. How do I write with a for loop in every 3rd cell
1 回表示 (過去 30 日間)
古いコメントを表示
I'm using a for loop to determine the stress state on each layer of a laminate. I need to write each vector in a column of an excel file.
I would like to wirte the first one in B32:B34 and the next in B35:B37 and so on for each layer.
for i=1:NumLayers
LaminaSress = Qs*(Strain+z(i)*Curve);
xlswrite(Filename,LaminaStress,1,'B32')
end
0 件のコメント
採用された回答
Guillaume
2019 年 3 月 24 日
One way:
LaminaSress = zeros(3, NumLayers); %assuming that the result of your equation is a 3 elements vector
for layer = 1:NumLayers
LaminaSress(:, layer) = Qs*(Strain+z(layer)*Curve);
end
xlswrite(Filename, LaminaStress, 1, 'B32');
Note that assuming that z is a vector and Qs or Strain and Curve are also vectors , your loop is not even needed. You can get the whole matrix in one go:
LaminaSress = Qs.*(Strain + z .* Curve); %some tranposition may be needed to make sure the vectors are along different dimensions
xlswrite(Filename, LaminaStress, 1, 'B32');
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Data Distribution Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!