Constant solving with eval() doesnt work
显示 更早的评论
Hi guys,
im rather new to Matlab, especially to the topic.
I need to integrate the q1 and q2 functions two times. Then I get the constants C1, C2, C3, C4. I have to solve these, considering the g1 functions (boundary conditions).
Later on I try to solve the functions with eval() and continue to get the solved constants.
But in the command window I get something like: "M2(x) = C4 + (x*(6*C3 + 6*q0*x))/6 - (q0*x^3)/(6*a)".
Does somebody know how to get the values of the constants for a=2 and q0=800? We have to use the eval() function....
Thanks a lot :)
clear
clear all
clc
% Definition symb vars
syms x a b C1 C2 C3 C4 q0
% define symbolic functions
q1(x) = 0*x
q2(x) = -(q0/a)*x + 2*q0
% symb. Integration
Q1(x) = int(q1,x) + C1
Q2(x) = int(q2,x) + C3
M1(x) = int(Q1,x) + C2
M2(x) = int(Q2,x) + C4
% Boundary conditions
g1 = subs(M1,x,0) == 0;
g2 = subs(M2,x,2*a) == 0;
g3 = subs(Q1,x,a) == subs(Q2,x,a);
g4 = subs(M1,x,a) == subs(M2,x,a);
% solve symb. functions
%C = solve(q,C)
[C1, C2, C3, C4] = solve([g1, g2, g3, g4], [C1, C2, C3, C4]);
% insert solutions
%Y(x) = eval(Y)
Q1(x) = eval(Q1);
Q2(x) = eval(Q2);
M1(x) = eval(M1);
M2(x) = eval(M2);
% insert values
a = 2;
q0 = 800;
Q1_num = eval(Q1);
% fprintf ("C1 = %f\n", C1);
%a = 5;
%b = 2;
%Y_num = eval(Y)
%fprintf ("C1 = %f\n", Q1_num);
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Code Performance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!