I am trying to solve these variables in terms of dQ3 and dQ5. (This is for structures homework, so we're dealing with virtual forces that will cancel in the end.) I am going to do it by hand, but I am still curious if there is a way to solve this in Matlab.
I looked at others' questions on Answers, but I only found examples of rearranging one equation instead of 10 simultaneously. dQ3 and dQ5 do not appear in all equations, so I am unsure how to specify that I want the solution in terms of these equations. Is this possible? Will it not work because the variables all have solutions that are 0?
clc;clear;%VIRTUAL
syms dY1 dX1 dY3 dQ3 dQ5 dP12 dP14 dP23 dP24 dP25 dP35 dP45eq1_v = 1.155*dY1 + dP14 == 0;eq2_v = dX1 + dP12 + 0.5*dP14 == 0;eq3_v = dP24 + dP25 == 0;eq4_v = dP23 + 0.5*dP25 - dP12 - 0.5*dP24 == 0;eq5_v = dY3 + 0.866*dP35 == 0;eq6_v = dQ3 - 0.5*dP35 - dP23 == 0;eq7_v = dP24 + dP14 == 0;eq8_v = dP45 + 0.5*dP24 - 0.5*dP14 == 0;eq9_v = dQ5 - dP25 - dP35 == 0;eq10_v = dP35 - dP25 - 2*dP45 == 0;eqs_v = [eq1_v eq2_v eq3_v eq4_v eq5_v eq6_v eq7_v eq8_v eq9_v eq10_v];Sv = solve(eqs_v, [dY1, dX1, dY3, dP12, dP14, dP23, dP24, dP25,... dP35, dP45], 'dQ3', 'dQ5');Sv.dY1Sv.dX1Sv.dY3Sv.dP12Sv.dP14Sv.dP23Sv.dP24Sv.dP25Sv.dP35Sv.dP45
This is just another side question; just wondering if I can be lazy:
Also, is this the neatest way to display the variables and their numerical solutions (simply outputting 'Sv.–')? Is there a way to make a table? I figured out how to sort the numerical answers into a matrix, but I can't find how to turn the variables into strings without rewriting an entire new matrix of strings. I used the "fieldnames" function to get the variable names from the solve structure, but it outputs a cell array of cell arrays. Is there a shortcut?
Best Answer