Changing the name of a variable changes the results?
Show older comments
I have very simple script that I am using to solve a set of simultaneous equations. Note the variable named "RB" (it stands for reaction force at point B). In it's current state the code geneates an erroneous solution for RB. The value should be 2.3467e+03 (or the negative of this value). However it reports 1.6762e+03, which, by the way, should be the solution for the variable "L". It's effectively flipping the results for variables "RB" and "L".
To address this issue, I simply have to change variable "RB" to "B" and it gives the correct results. Why does simply changing the name of a variable change the output? Does placing an "R" in front of a variable somehow reverse its value? It is recognizing "RB" as a variable.
Your insights appreciated!
% Clear Commands
clc; clear all;close all;
% define symbolic variables
syms RB L theta;
%this makes output real numbers
sympref('floatingpointoutput',true);
% here are the equations from the hand set up
e1=RB*cosd(30)+3500*cosd(theta);
e2=-L+3500*sind(theta)-RB*sind(30);
e3=(0.35*L)-(0.25*RB);
% solve for the unknowns (all in kN)
[RB, L, theta]=solve(e1,e2,e3);
RB
L
theta
Accepted Answer
More Answers (0)
Categories
Find more on Equation Solving 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!