I am trying to create and sum up Anonymous Functions using for loops so that I can plot it. Please help me to understand how to correct the syntax, or if this is even valid to do.
clearclcterms = input('How many terms are there for the loading? ');L = input('What is the beam length? ');disp('')disp('A<X-B>^C')wA = zeros(terms,1);vA = zeros(terms,1);B = zeros(terms,1);wC = zeros(terms,1);vC = zeros(terms,1);shear = zeros(terms,1);SHEAR = 0;x = 0:1/(L*100):L;%inputs the values of the static loading
for i = 1:terms fprintf('\nThe term is %i\n',i) wA(i) = input('The value of A: '); B(i) = input('The value of B: '); wC(i) = input('The value of C: ');end%calculates the singularity function for the shear
for j = 1:terms if wC(j)>=0 vA(j) = wA(j)/(wC(j)+1); vC(j) = wC(j)+1; else vA(j) = wA(j); vC(j) = wC(j)+1; endend%Combines the SHEAR terms into one function
for s = 1:terms if vB(s) == L s = s+1; end if vC(s) > 0 shear{s} = @(x) vA(s)*(x.^(vC(s)).*heaviside(x-vB(s)); elseif vC(s) == 0 shear{s} = @(x) vA(s).*heaviside(x-vB(s)); elseif vC(s)< 0 shear{s} = 0; end SHEAR = SHEAR(x) + shear{s}(x);end%PLOT OF SHEAR VS X
figure(1) plot(x,SHEAR) title 'Shear force as a function of X' xlabel 'Shear' ylabel 'Length'
Best Answer