Array values assigned to for loop
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
t = truss(X, edges, k)
% t: tension in edges
t = [-0.5 ; 1.5811 ; -1.5811]
% yield strength
sigmay = 0.3;
A = edgeArea;
T = sigmay .* A;
N=1;
for i = t(N):t(N+1,:)
if i > 0 ; i < T;
disp(i)
disp('edge does not yield')
elseif i > T;
disp(i)
disp('edge yeilds')
else i < 0;
disp(i)
disp('edge is negative, check buckle')
end
end
I want to run the code so the value of t(1) [-0.5] is ran and solved and displayed then t(2) [1.5811] is and then finally t(3) [-1.5811].
0 commentaires
Réponses (1)
Eric Delgado
le 28 Oct 2022
Modifié(e) : Eric Delgado
le 28 Oct 2022
Try this...
t = [-0.5; 1.5811; -1.5811];
T = 1;
for i = 1:numel(t)
if t(i) > 0 & t(i) < T
msg = 'edge does not yield';
elseif t(i) > T
msg = 'edge yeilds';
else
msg = 'edge is negative, check buckle';
end
fprintf('%.4f - %s\n', t(i), msg)
end
0 commentaires
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!