Why can't matlab solve if a constant value is supplied?
11 views (last 30 days)
Show older comments
I've made a file to calculate the maximum effective stress for a dam. Given h is the height of the caisson.
h=0:1:10
M = ((1025*0.5*(1/3)*h^3)
When h is increased till 11 M becomes the formula as in the M-file. The error gives an error
((??? Error using ==> mupadmex
Error in MuPAD command: Invalid index [list];
during evaluation of 'matchNonSingletonLHS'
Error in ==> sym.sym>sym.subsasgn at 1420
C = mupadmex('mllib::subsasgn',A.s,B.s,inds{:});
Error in ==> s at 14
sol(i,1) = solve(f,x);))
clc
close all
clear all
i=1;
for
h=11:1:30
syms x
M = ((1025*0.5*(1/3)*h^3)-(1025*0.5*(1/3)*((h-10)^3)));
V = (2*(h-2)+2*x)*2400*9.81+((h-2)*(x-2))*1800*9.81-(h*x)*1025*9.81;
f = (V/x)+((6*M)/x^2)-500;
sol(i,1) = solve(f,x);
i=i+1;
end
eval(sol)
What goes wrong??
0 Comments
Accepted Answer
Walter Roberson
on 20 Dec 2013
I do not have that toolbox to test with, but I suggest you do not loop:
syms x h
M = ((1025*0.5*(1/3)*h^3)-(1025*0.5*(1/3)*((h-10)^3)));
V = (2*(h-2)+2*x)*2400*9.81+((h-2)*(x-2))*1800*9.81-(h*x)*1025*9.81;
f = (V/x)+((6*M)/x^2)-500;
solsym = solve(f,x);
sol = double(subs(solsym, h, 11:1:30));
0 Comments
More Answers (1)
A Jenkins
on 20 Dec 2013
Edited: A Jenkins
on 20 Dec 2013
Your "f" does not have a real valued solution (it has imaginary components). Perhaps you have an error in your equations for M and V?
>> f = (V/x)+((6*M)/x^2)-500
f =
((381609*x)/4 + 105948)/x + 5855114166271999/(4294967296*x^2) - 500
>> solve(f,x)
ans =
- 0.55819540632598278755245528952159 + 3.7487595937264604137316453147829*i
- 0.55819540632598278755245528952159 - 3.7487595937264604137316453147829*i
0 Comments
See Also
Categories
Find more on Special Values 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!