Values used to run a for loop
Show older comments
Hi, I'm trying to model the strength of a cable that consist of N wires, subjected to strain loading (epsilon). To find the strength of the cable I use 2 for loops and some IF sentences. Since I want to find the strength of the cable based on the strain, I want epsilon to start at zero and calculated at certain steps (a in script) towards a described end value (k in script). If I start with epsilon = 0 then I get: Attempted to access jobb(0); index must be a positive integer or logical. Is there a way that my epsilon value can go from zero and I can have smaler calculation steps than 1? The script works when epsilon = 1 and step = 1..
Here is my script:
clc; clear all; close all;
E = 7.75*1e4;
Area = 38.48;
my = 0.8686;
sy = 0.1318;
mu = 0.4343;
su = 0.3295;
k = 8;
a = 1;
N = 200;
epsilon_0 = 0;
jobb = zeros(k,1);
P = rand(N,1);
epsilon_y = logninv(P,my,sy);
epsilon_u_y = logninv(P,mu,su);
epsilon_u = (epsilon_y + epsilon_u_y);
n = numel(P);
g = 1:a:k;
model = zeros(n,1);
for epsilon = (0+epsilon_0):a:k;
for ii = 1:n;
if epsilon_y(ii) >= epsilon
ep = epsilon;
elseif epsilon_y(ii) < epsilon && epsilon < epsilon_u(ii)
ep = epsilon_y(ii);
elseif epsilon_u(ii) <= epsilon
ep = 0;
end
model(ii) = ((ep/100)*E);
end
p = sum(model)*Area;
jobb(epsilon) = p;
end
Best regards
Trond Oesten
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!