Cannot figure out what went wrong

Hi all, I am actually using Octave, but it is similar to Matlab so I figure I should get it a shoot here. I have a problem while trying to do numerical solution. I got the following error while trying to run the script.
When I tried to remove the ";" I will get the following error.
I also noticed that there is nothing in the workspace. The weird part is that the code works just fine on my friend's Octave. I just copy and paste the code into my computer, but it does not run the script. Can anyone please help?

3 Comments

Copy the code here...not image.....image snippet is not going to hlep any manner for checking.
z = 25;
l = 2500;
L0 = (z^2+l^2)^.5;
ks = 1.35;
EA = 50000000;
F_ext = 200;
v = [0:0.1:70]';
f_ext = EA*(L0-((z-v).^2+l^2).^0.5)/L0.*(z-v)/(((z-vI(i))^2+l^2)^0.5)+ks*v;
plot(v,f_ext); xlabel('v (mm)'); ylabel('f_e_x_t (N)');
vI = 0;
fI_ext = 0;
n = 50;
DF = F_ext/n;
Ki = [];
Dvi = [];
for i = 1 : n
Li = ((z-vI(i))^2+l^2)^0.5;
K = EA/L0 * ( (Li-L0)/Li+((z-vI(i))^2/(Li^2)) + ks;
Dv = K^-1*DF;
vI(i+1) = vI(i)+Dv;
fI_ext(i+1) = fI_ext(i)+DF;
Ki = [Ki;K];
Dvi = [Dvi;Dv];
end
hold on; plot(vI,fI_ext,'o--')
@Daniel check Steven's answer

Sign in to comment.

 Accepted Answer

Steven Lord
Steven Lord on 10 Oct 2018
Count your parentheses.

2 Comments

+1 @steven scrutinised precisely.
z = 25;
l = 2500;
L0 = (z^2+l^2)^.5;
ks = 1.35;
EA = 50000000;
F_ext = 200;
v = [0:0.1:70]';
% f_ext = EA*(L0-((z-v).^2+l^2).^0.5)/L0.*(z-v)/(((z-vI(i))^2+l^2)^0.5)+ks*v; error was here also because you can't subtract scalar with vector
%
% plot(v,f_ext); xlabel('v (mm)'); ylabel('f_e_x_t (N)');
vI = 0;
fI_ext = 0;
n = 50;
DF = F_ext/n;
Ki = [];
Dvi = [];
for i = 1 : n
Li = ((z-vI(i))^2+l^2)^0.5;
K = EA/L0 * ( (Li-L0)/Li+((z-vI(i))^2/(Li^2))) + ks; %error here as steven said one closing parentheses was missing here
Dv = K^-1*DF;
vI(i+1) = vI(i)+Dv;
fI_ext(i+1) = fI_ext(i)+DF;
Ki = [Ki;K];
Dvi = [Dvi;Dv];
end
hold on; plot(vI,fI_ext,'o--')

Sign in to comment.

More Answers (1)

Categories

Products

Tags

Asked:

on 10 Oct 2018

Answered:

on 10 Oct 2018

Community Treasure Hunt

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

Start Hunting!