Creating an arbitary symbolic matrix in Matlab

  • Thread starter Thread starter EbolaPox
  • Start date Start date
  • Tags Tags
    Matlab Matrix
AI Thread Summary
To create an n by n symbolic matrix in MATLAB with variable names in the form aij, a user seeks guidance on using loops to generate these symbolic variables. The user suggests starting with a loop from 0 to n to create the first row but is uncertain about the correct syntax for naming the symbolic variables. Another participant notes that implementing this task would likely require two nested loops, which is a common approach in programming. The discussion highlights the need for proper syntax and structure in MATLAB for generating symbolic variable names dynamically. Overall, the conversation centers on finding an effective method to achieve the desired matrix format in MATLAB.
EbolaPox
Messages
99
Reaction score
1

Homework Statement


Hi everyone, I'm new to using MATLAB and had a quick question. I'm trying to write a function such that my input into it is a number, say n, and it produces an n by n matrix with symbolic variables with names of the form aij , where i and j are numbers that refer to its row and column positions. This didn't seem like it would be too terribly tough, but I'm not sure how to make give my matrix these variable names of the form aij. I figured I could write a loop of some form that went from 0 to n and gave each an a1n or something of that form name, just to get at least one row, but I'm not too sure what syntax to use to give the symbolic variable its name. I was hoping I could write a loop with a variable i that ranged from 0 to n, and then do something like syms a'i' or something like that. I thought maybe if I turned the number i into a string, I could do something like that to make a bunch of symbolic variables, but I still had no luck. Any suggestions would be very appreciated. Thanks!
 
Physics news on Phys.org
I'm not familiar with Matlab. But wouldn't this involve two nested loops, no matter what programming language is used?
 
Thread 'Have I solved this structural engineering equation correctly?'
Hi all, I have a structural engineering book from 1979. I am trying to follow it as best as I can. I have come to a formula that calculates the rotations in radians at the rigid joint that requires an iterative procedure. This equation comes in the form of: $$ x_i = \frac {Q_ih_i + Q_{i+1}h_{i+1}}{4K} + \frac {C}{K}x_{i-1} + \frac {C}{K}x_{i+1} $$ Where: ## Q ## is the horizontal storey shear ## h ## is the storey height ## K = (6G_i + C_i + C_{i+1}) ## ## G = \frac {I_g}{h} ## ## C...
Back
Top