Resizing Matrix - Copy / Paste Matrix - How to Resize - Сообщения
Is a solution here?
See attached example.
Thank you!!
Beam - Uniform - Multiple Beam.sm (18 КиБ) скачан 54 раз(а).
However when you have repetitive tasks the best way is to build a couple of functions with input argument LG and output argument a vector or a system containing the loads and the moments (this is safe and there's no needs to unset something).
Best regards,
Davide
ЦитатаOtherwise the best way is to build a couple of functions with input argument LG and output argument a vector or a system containing the loads and the moments.
I'm not sure what you mean by this. What is a "system" containing the loads and moments?
Thanks again

WroteI'm not sure what you mean by this. What is a "system" containing the loads and moments?
Something like this in the attachment
Beam - Uniform - Multiple Beam.sm (40 КиБ) скачан 91 раз(а).
So bascially you defined a function, loads(). I should make a point to remeber that this is a function not a matrix therefor you must define a matrix also named loads = loads(LG). This is required because you cannot call for values contained in the loads(LG) function.
However now that I have this function I can reuse it throughout the page. Very nice.
questions:
What is the "#" symbol for?
What is the systems symbol for, meaning what does it do? It just inputs vectors into a matrix?
thanks again
Wrotequestions:
What is the "#" symbol for?
What is the systems symbol for, meaning what does it do? It just inputs vectors into a matrix?
I use #var for "local" variables, so any other variable is "global" (loads is not only function of LG, also of LF.DL etc...); I strongly suggest to use some trick like this, for a fast and easy debug/maintenance (you can use #var _var `var Var VAR or whatever is the best way for you... to add the # symbol before the word, write the word and then move the text cursor to the first character and place the symbol)
About functions remember these rules:
- any variable created inside the function is 'local';
- you can get variables from outside the function, if doesn't exists inside the function;
- if you define a new value for an input argument, this is global (affects the input variable outside the function) (this is called "passing by reference", if I remember correctly the official name of this feature)
In your worksheet, when you define [math eng]el(b.trib,1)[/math] inside the function, SMath as first thing attempts to replace the first matrix element; because doesn't exist yet as local variable, Smath looks in the worksheet for a global variable: if exist will be used as base inside the loop (and here you are back to the issue of the first post), otherwise initialize an empty matrix. Using a name "hardly utilizzable on the canvas", you skip any issue.
As you can see copying a not filled function from SMath to a text editor, # is used as empty placeholder; this is why you can't write directly a variable using # as first character

Best regards,
Davide
P.S. the dynamic assistance show you that loads is a function; however you can set a description text to point out this fact.
WroteI'm wondering if I could apply the concept of functions to 'function' as "engine pages" ...
Basically I have a bunch of different input that I can send to the function multiple times on a page. hmmmm....
This would work. The disadvantage is that you cannot use ordinary SMath sheets as function descriptions. Instead, you have to write sort of
program (using the line() operator) to do the job.
Before designing the functions you perhaps might consider to define
- the problem data structure and methods to apply to this data structure
- methods data structure like tables, only accessed within the methods
Both structures can be just global variables or single complex objects. You can fake objects with named attributes by using a 2-column matrix with name strings in the first column and whatever object in the second column and define a corresponding set(structure,name,value) and get(structure,name) function pair.
Functions can provide return values and can modify arguments, if these are given as names (call by reference). They cannot modify global variables (any assignment to a name which does not occure in the formal parameters list creates a local variable, shadowing global objects of the same name).
One quick question -
I tried to update my previous post to include moments but seem to be struggling to do so.
I've attached the calculation and hope you can make sense of it. I'm not sure why I'm receive these errors.
Also what is the output window for?
Thanks again!
Creating functions Beam - Uniform - Multiple Beam.sm (48 КиБ) скачан 40 раз(а).
WroteThanks for the further comments.
One quick question -
I tried to update my previous post to include moments but seem to be struggling to do so.
I've attached the calculation and hope you can make sense of it. I'm not sure why I'm receive these errors.
Also what is the output window for?
Thanks again!
The problem is in the mismatch between data structure and indexing. You have a vector of row matrices and try to access the elements just as in a matrix. You have to use nested index levels.
The output window displays the output of trace(), a function for debugging, explained in the wiki
So how should I handle this? I suppose I could adjust the Moments () function so that I send the individual row matrices to the function (i.e. Moments(#w.tot, #L.b, #R))
Or is there another way I can extract the individual row matrices from the LoadsM vector?
Possibly ->
first step through the number of columns of the vector (which is 1) then step through the number of columns of the row matrices?
Thanks again!!
WroteI see what you're saying (I think)... so what I call LoadsM is not a matrix, it is actually a vector ("vector of row matrices").
To be precise, it is defined as a list (system) of row vectors. Here is a comparison of lists and column vectors:
properties they have in common:
- linear (1D) array of arbitrary objects
- access to elements via index function el()
Lists
- are marked by a left curly brace with the elements aligned left
- functions rows() or length() do not work, there is no way to determine the number of elements except converting to a vector via sys2mat() and then applying the
- can be used instead of scalars in expressions. If multiple lists occure within an expression, then all combinations of elements are used and a corresponding list is returned.
- are more convenient to type (just type sys TAB ).
column vectors:
- are marked with a pair of parens and the elements centered.
- are less convenient to type (use Ctrl-M, adjust numbers of cols and rows or type mat( and resize using the mouse).
- can be used as iterators for loops
- can be operator of matrix multiplication or scalar product
There is much more on lists and matrices in the chapter Mathematics in the interactive handbook. Before making
program structure decisions, you might consider making yourself familiar with the available functions.
The screenshot in my previous post shows how to access the elements.
el(loadsM,j) extracts the j-th element (a row vector) of the list
el(el(loadsM,j),k) extracts the k-th element (a number) of the j-th element.
For iteration over all elements, vectors and matrices are better suited than lists. First, you easily can determine their size, second, you even might use them directly as range in the for statement.
loadsM[1[1
Then you receive an error
if you type:
loadsM[1spacebar[spacebar
Then I receive the correct result
So for this problem what is the best way to set up the calculation?
1. Use systems. When I setup my range I can transform the system into a matrix. Then I can access the elements as noted above my Martin.
2. in the loads() function I don't put values into a system. Instead I put them back into a matrix. More work but possibly worth the effort. Maybe there is anothway. I will have to play with it some.
When creating functions, instead of return a system (like we did above), how would you return a matrix?
Sorry for all the questions. Thanks.
There is one interesting error however which is that it returns one of the matrices as undefined (see attached).
Thanks!
Creating functions Beam - Uniform - Multiple Beam.sm (72 КиБ) скачан 39 раз(а).
WroteThere is one interesting error however which is that it returns one of the matrices as undefined (see attached).
Thanks!
You are victim of bug SS-40. Andrey has marked it as fixed but did not yet roll out the fixed version.
You can identify such problems by setting the cursor on some name and watching if all occurences of that name are highlighted in the expression. If not, then there might be a typo or a hidden empty text index.
See the marked spot in the attachment and compare this to your original file.
Edit: The useless error message is just another known bug...
-
Новые сообщения
-
Нет новых сообщений