フィルターのクリア

For loop problem for matrix

1 回表示 (過去 30 日間)
Syed Abdul Rafay
Syed Abdul Rafay 2023 年 11 月 29 日
コメント済み: Syed Abdul Rafay 2023 年 12 月 1 日
This is my code I am trying to make a matrix where I can record the values when n value changes in columns and when k value changes in rows like a matrix A[k xi]. When xi value changes VGL_xi value changes which then is used to calculate the VUGPL VXGPL VOGPL VAGPL. There are 10 segments in Z direction and 14 segments in x direction when VGPL_xi changes I have to calculate 10 values of VUGPL VXGPL VOGPL VAGPL and similarly when again VGPL_xi value change again 10 Values for VUGPL VXGPL VOGPL VAGPL. I will get a matrix of 10 x 14
clc
rhoGPL = 1062.5;
% kg/m^3
rhom = 1200;
% kg/m^3
rhoMWCNT = 1700;
% kg/m^3
rhoSWCNT = 1400;
% kg/m^3
rhoEpoxy = 1100;
% kg/m^3
a = 2.5e-6; % length of GPL
% units in meters
t = 1.5e-9; % thickness of GPL
% units in meters
b = 1.5e-6; % width of GPL
% units in meters
EGPL = 1.01e+12;
% units in Pascal
Em = 3e+09;
% units in Pascal
h = 0.01; % height of GOP Beam
% units in meters
csi_long = 2 * (a / t);
csi_trans = 2 * (b / t);
num = 0.34;
% poisson ratio of matrix
nuGPL = 0.186;
WL=0.003; %weight fraction on left
Wr=0.001; % weight fraction on right
VL= WL / (WL + ((rhoGPL / rhom) * (1 - WL))); %volume fraction on left
Vr= Wr / (Wr + ((rhoGPL / rhom) * (1 - Wr))); %volume fraction on right
nu=3; %gradiant parameter according to which the properties are changing along axial direction
n=14;% number of segments inx direction
% xi=0:1/n:1;
% VGPL_xi= (VL*(1-((exp(nu*xi)-1)/(exp(nu)-1))))+(Vr*((exp(nu*xi)-1)/(exp(nu)-1)));
% Vm=1-VGPL_xi;
N=10;% number f segments in z direction
A=zeros(N,n);
for xi=0:1/n:1
VGPL_xi= (VL*(1-((exp(nu*xi)-1)/(exp(nu)-1))))+(Vr*((exp(nu*xi)-1)/(exp(nu)-1)));
Vm=1-VGPL_xi;
for K = 1:1:N
VUGPL = VGPL_xi;
V2GOP1(K) = VUGPL;
Vm1(K) = 1 - VUGPL;
rhoplatelet1(K) = (rhoGPL * VUGPL) + (rhom * Vm1(K));
eta_long = ((EGPL / Em) - 1) / ((EGPL / Em) + csi_long);
eta_Trans = ((EGPL / Em) - 1) / ((EGPL / Em) + csi_trans);
E_long1 = ((1 + (csi_long * eta_long * VUGPL)) / (1 - (eta_long * VUGPL))) * Em;
E_Trans1 = ((1 + (csi_long * eta_Trans * VUGPL)) / (1 - (eta_Trans * VUGPL))) * Em;
nu_beam1(K) = (num * Vm1(K)) + (nuGPL * VUGPL);
Ebeam1(K) = ((3 / 8) * E_long1) + ((5 / 8) * E_Trans1);
A(Ebeam1,:)=[K,xi];
end
end
clear V2GOP2 Vm2 rhoplatelet2 nu_beam2 Ebeam2;
for xi=0:1/n:1
VGPL_xi= (VL*(1-((exp(nu*xi)-1)/(exp(nu)-1))))+(Vr*((exp(nu*xi)-1)/(exp(nu)-1)));
Vm=1-VGPL_xi;
for K = 1:1:N
VXGPL = 2 * VGPL_xi * abs((2 * K) - N - 1) / N;
V2GOP2(K) = VXGPL;
Vm2(K) = 1 - VXGPL;
rhoplatelet2(K) = (rhoGPL * VXGPL) + (rhom * Vm2(K));
eta_long = ((EGPL / Em) - 1) / ((EGPL / Em) + csi_long);
eta_Trans = ((EGPL / Em) - 1) / ((EGPL / Em) + csi_trans);
E_long2 = ((1 + (csi_long * eta_long * VXGPL)) / (1 - (eta_long * VXGPL))) * Em;
E_Trans2 = ((1 + (csi_long * eta_Trans * VXGPL)) / (1 - (eta_Trans * VXGPL))) * Em;
nu_beam2(K) = (num * Vm2(K)) + (nuGPL * VXGPL);
Ebeam2(K) = ((3 / 8) * E_long2) + ((5 / 8) * E_Trans2);
end
end
clear V2GOP3 Vm3 rhoplatelet3 nu_beam3 Ebeam3;
for xi=0:1/n:1
VGPL_xi= (VL*(1-((exp(nu*xi)-1)/(exp(nu)-1))))+(Vr*((exp(nu*xi)-1)/(exp(nu)-1)));
Vm=1-VGPL_xi;
for K = 1:1:N
VOGPL = 2 * VGPL_xi * (1-abs((2 * K) - N - 1)/ N) ;
V2GOP3(K) = VOGPL;
Vm3(K) = 1 - VOGPL;
rhoplatelet3(K) = (rhoGPL * VOGPL) + (rhom * Vm3(K));
eta_long = ((EGPL / Em) - 1) / ((EGPL / Em) + csi_long);
eta_Trans = ((EGPL / Em) - 1) / ((EGPL / Em) + csi_trans);
E_long3 = ((1 + (csi_long * eta_long * VOGPL)) / (1 - (eta_long * VOGPL))) * Em;
E_Trans3 = ((1 + (csi_long * eta_Trans * VOGPL)) / (1 - (eta_Trans * VOGPL))) * Em;
nu_beam3(K) = (num * Vm3(K)) + (nuGPL * VOGPL);
Ebeam3(K) = ((3 / 8) * E_long3) + ((5 / 8) * E_Trans3);
end
end
clear V2GOP4 Vm4 rhoplatelet4 nu_beam4 Ebeam4;
for xi=0:1/n:1
VGPL_xi= (VL*(1-((exp(nu*xi)-1)/(exp(nu)-1))))+(Vr*((exp(nu*xi)-1)/(exp(nu)-1)));
Vm=1-VGPL_xi;
for K = 1:1:N
VAGPL = VGPL_xi * abs((2 * K) - 1) / N;
V2GOP4(K) = VAGPL;
Vm4(K) = 1 - VAGPL;
rhoplatelet4(K) = (rhoGPL * VAGPL) + (rhom * Vm4(K));
eta_long = ((EGPL / Em) - 1) / ((EGPL / Em) + csi_long);
eta_Trans = ((EGPL / Em) - 1) / ((EGPL / Em) + csi_trans);
E_long4 = ((1 + (csi_long * eta_long * VAGPL)) / (1 - (eta_long * VAGPL))) * Em;
E_Trans4 = ((1 + (csi_long * eta_Trans * VAGPL)) / (1 - (eta_Trans * VAGPL))) * Em;
nu_beam4(K) = (num * Vm4(K)) + (nuGPL * VAGPL);
Ebeam4(K) = ((3 / 8) * E_long4) + ((5 / 8) * E_Trans4);
end
end
rhoplatelet1
Ebeam1
nu_beam1
rhoplatelet2
Ebeam2
nu_beam2
rhoplatelet3
Ebeam3
nu_beam3
rhoplatelet4
Ebeam4
nu_beam4
  2 件のコメント
Steven Lord
Steven Lord 2023 年 11 月 29 日
It's not clear to me what help you're looking for. What problem are you experiencing or what question do you have about how this code has been written or runs?
Syed Abdul Rafay
Syed Abdul Rafay 2023 年 11 月 30 日
Actually I want to record the values in a matrix. There are two values which are changing VGPL_xi and values that depend on K and VGPL_xi.

サインインしてコメントする。

回答 (1 件)

Steven Lord
Steven Lord 2023 年 11 月 30 日
There are two values which are changing VGPL_xi and values that depend on K and VGPL_xi.
Ah. So you're trying to figure out how to go from multiple variables with numbered names to one variable with multiple elements?
This MATLAB Answers post offers several alternative approaches that don't involve creating variables with numbered names.
  1 件のコメント
Syed Abdul Rafay
Syed Abdul Rafay 2023 年 12 月 1 日
Yes

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGeneral Applications についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by