App designer for composite bars for n inputs

3 次查看(过去 30 天)
Hey there, I am trying to build an app for composite bars, the inputs depend on the user's requirement. How do i get multiple inputs window ? (for ex: if n= 10, the edit field boxes must be the n for further inputs (i.e 10). Here's my code for the same on matlab
disp('1 - Circular cross-section');
disp('2 - Rectangular cross-section');
choice = input('Enter the type of cross-section: ');
n = input('Enter the number of cross-sections: ');
F = input('Enter the load in N: ');
if choice==1;
A=zeros(n,1)
Delta=A;
for i=1:n
fprintf('Enter the Youngs modulus of Bar %i : \n',i );
E = input('y =');
fprintf('Enter the length of Bar %i: \n',i );
L = input('b =');
fprintf('Enter the diameter of Bar %i:\n',i );
D = input('s =');
A(i,1) = (pi*(D^2)/4 );
Delta(i,1) = ((F*L)/(A(i,1)*E ));
end
for j=1:n
fprintf(' Total extension of the bar %i: %f. \n' ,j,Delta(j,1 ) );
end
elseif choice==2;
A=zeros(n,1)
Delta=A;
for i=1:n
fprintf('Enter the Youngs modulus of Bar %i : \n',i );
E = input('y =');
fprintf('Enter the length of Bar %i: \n',i );
L = input('b =');
fprintf('Enter the breadth of Bar %i:\n',i );
D = input('s =');
A(i,1) = L*D;
Delta(i,1) = ((F*L)/(A(i,1)*E ));
end
for j=1:n
fprintf(' Total extension of the bar %i: %f. \n' ,j,Delta(j,1 ) );
end
end

回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by