Solve a system of symbolic variables
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi,
I have been trying hard at this for a while now. Does anybody know if there is some way to solve symbolic variables in a matrix, resulting in a double format?
I want to solve for the unknowns of F and d. The amount of unknowns depends on the values specified in the input:
% This program calculates any straight equal-length element analysis
% for a bar with two fixed ends
syms Freact1 Freact2;
A = input('Cross-sectional area (mm^2): ');
E = input('Elastic Modulus (MPa): ');
L = input('Length of the system (mm): ');
num_ele = input('Enter the number of elements to be analyzed: ');
num_nodes = num_ele + 1;
k = (E*A)/(L/num_ele);
F = zeros(num_nodes,1);
d = zeros(num_nodes,1);
d(1) = 0; d(num_nodes) = 0;
F1 = vpa(Freact1); Fend = vpa(Freact2);
F(1) = F1; F(num_nodes) = Fend;
disp(' ');
for i = 2:num_ele
str = sprintf('Node %d: ', i);
disp(str);
F(i) = input('Enter the force at the node (N): ');
disp(' ');
end
glbl_stiff = 0*diag(num_nodes,num_nodes-1) + 2*eye(num_nodes);
glbl_stiff(1,1) = 1; glbl_stiff(num_nodes,num_nodes) = 1;
for j = 1:num_ele
glbl_stiff(j,j+1) = -1;
glbl_stiff(j+1,j) = -1;
end
glbl_stiff = k*glbl_stiff;
F = glbl_stiff*d
d = F\glbl_stiff
and the error that always results:
The following error occurred converting from sym to
double:
Error using mupadmex
Error in MuPAD command: DOUBLE cannot convert the
input expression into a double array.
If the input expression contains a symbolic
variable, use the VPA function instead.
Error in FEM_IA1 (line 20)
F(1) = F1; F(num_nodes) = Fend;
It's confusing because I did use the VPA function. It just seems like nothing's working.. any ideas would greatly be appreciated.
Thanks, Ian
0 Commenti
Risposte (3)
Star Strider
il 16 Ott 2012
Modificato: Star Strider
il 16 Ott 2012
The variables Freact1 and Freact2 in that line are symbolic variables. You haven't assigned any numeric values to them.
14 Commenti
Star Strider
il 17 Ott 2012
I'll keep this open until we're happy we've converged on a solution then.
Matt Fig
il 16 Ott 2012
Use symbolic arrays instead:
F = sym(zeros(num_nodes,1));
d = sym(zeros(num_nodes,1));
3 Commenti
Phan HaNhut
il 26 Gen 2014
if memory of computer is slow, code can not end? (matlab: "busy") And there is not any result?
I have to add more RAM?
Walter Roberson
il 26 Gen 2014
If your memory is limited, then you can speed up operations by turning off virtual memory (or configuring it to be size 0). Swapping memory to disk is very very slow, and my practical experience on MS Windows systems is that once you swap enough program memory to disk then you cannot make any progress because you run into "thrashing" (part of memory you need for the calculation is swapped out in order to bring in something else you need, but then that has to get swapped out in order to bring the first back in in order to proceed, but then that needs... etc.) Turning off virtual memory would result in the calculation failing cleanly with complaints about insufficient memory instead of running for days getting nowhere.
Expanding physical memory is usually good. You may need to switch to a 64 bit operating system (with the extra memory) to make real progress.
Ian Wood
il 17 Ott 2012
3 Commenti
Star Strider
il 18 Ott 2012
Scanning the book you referred me to earlier (the discussions on pages 46-7), it seems that you would solve independently for the forces with zero (or other defined) displacements and then for the displacements with known forces as separate procedures.
So you would for instance solve for d2 as a linear equation with a force of 1000, then use sparse matrix techniques to solve for F1 and F3 with displacements = 0. That seems to be what the book suggests, and that's certainly how I would do it. It doesn't seem mathematically possible to do both simultaneously, since that would mean having unknowns on both sides of the equation.
Vedere anche
Categorie
Scopri di più su Special Values in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!