Why can't matlab solve if a constant value is supplied?
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??
Accepted Answer
More Answers (1)
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
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!