Cell calculation and for loop modification

4 visualizaciones (últimos 30 días)
Mark
Mark el 15 de Nov. de 2021
Respondida: Srivardhan Gadila el 18 de Nov. de 2021
I would like to input my "stacknumber" and input my "theta(45,-45,0 repectively)" and save my value in the cell which is called "QbarStoreArr"
If I input the value of my stacknumber for 1, and input my "theta(45,-45,0 repectively)" in the Matlab Workspace I got the 1x3cell and each cell is a matrics.
But when I input the value of my stacknumber greater than 1 (That is, 2 3 4 5 6.....etc), in the Matlab Workspace I got only the first 3 cell and the rest is empaty space.
I would like to stack my cell result like this picture below(please input the value of my stacknumber=6 and input and input the value of theta 45,-45,0 repectively), how should I modify my code in "foor loop" to get the result I want?
Thanks!!
clc
clear
stackNumber = input('stackNumber = ');
plyNumber=3;
plysym=1;
Total=plyNumber*stackNumber*plysym;
QbarStoreArr = cell(1,Total);
E1=141;
E2=6.7;
G12=3.2;
v12=0.33;
v21 = v12*(E2/E1);
Q11 = E1./(1-v12.*v21);
Q12 =(v12.*E2)./(1-v12.*v21);
Q21 = Q12;
Q22 = E2./(1-v12.*v21);
Q66 = G12;
%========= Stacking
for i =1 : plyNumber
angleArr(1,i) = input(' theta = '); % Enter the plyNumber
QbarStoreArr{i} = QBarFunction(Q11, Q12, Q22, Q66, angleArr(1,i));
end
function [Qbar] = QBarFunction (Q11, Q12, Q22, Q66, x)
c=cosd(x); s = sind(x);
Q_bar_11=Q11.*(c.^4)+Q22.*(s.^4)+2.*(Q12+2.*Q66).*(s.^2).*(c.^2);
Q_bar_12=(Q11+Q22-4.*Q66).*(s.^2).*(c.^2)+Q12.*((c.^4)+(s.^4));
Q_bar_22=Q11.*(s.^4)+Q22.*(c.^4)+2*(Q12+2.*Q66).*(s.^2).*(c.^2);
Q_bar_16=(Q11-Q12-2.*Q66).*(c^3).*(s)-(Q22-Q12-2.*Q66).*(c).*(s.^3);
Q_bar_26=(Q11-Q12-2.*Q66).*(c).*(s^3)-(Q22-Q12-2.*Q66).*(c^3).*(s);
Q_bar_66=(Q11+Q22-2.*Q12-2.*Q66).*(s.^2).*(c.^2)+Q66.*((s^4)+(c^4));
Qbar= [Q_bar_11 Q_bar_12 Q_bar_16; Q_bar_12 Q_bar_22 Q_bar_26; Q_bar_16 Q_bar_26 Q_bar_66];
end

Respuestas (1)

Srivardhan Gadila
Srivardhan Gadila el 18 de Nov. de 2021
In the above code, the size of for loop is depending on the value of the variable "plyNmber", whose value is always 3.
for i = 1:plyNumber
angleArr(1,i) = input(' theta = ');
QbarStoreArr{i} = QBarFunction(Q11, Q12, Q22, Q66, angleArr(1,i));
end
Hence you have to change the above code to depend on the value of the variable "Total" which changes based on the value of the variable "stackNumber"
for i = 1:Total
angleArr(1,i) = input(' theta = ');
QbarStoreArr{i} = QBarFunction(Q11, Q12, Q22, Q66, angleArr(1,i));
end

Categorías

Más información sobre Phase-Locked Loops en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by