Write 3x1 matrix to excel file in for loop. How do I write with a for loop in every 3rd cell
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Michael Whipple
am 24 Mär. 2019
Kommentiert: Michael Whipple
am 25 Mär. 2019
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 Kommentare
Akzeptierte Antwort
Guillaume
am 24 Mär. 2019
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');
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!