Skip to main content
1-Visitor
March 8, 2023
Solved

For loop outputs 1x1 vectors into a matrix instead of scalars

  • March 8, 2023
  • 2 replies
  • 1298 views

I am analyzing a ground motion applied to a SDOF structure and finding the motion with Newmark's method. 

To accomplish this I have read the ground motion in with the readexcel function and then use a for loop to find the relative displacement, acceleration and velocity for each time step.

 

The file used and the needed excel file are attached.

 

 

 

 

 

Best answer by Werner_E

In the calculation of p.hat you typed square brackets! Never do this unless you want to create a matrix/vector. Always use (round) parentheses to group expressions.

Werner_E_0-1678300492162.png

 

2 replies

Werner_E25-Diamond IAnswer
25-Diamond I
March 8, 2023

In the calculation of p.hat you typed square brackets! Never do this unless you want to create a matrix/vector. Always use (round) parentheses to group expressions.

Werner_E_0-1678300492162.png

 

23-Emerald IV
March 8, 2023

You've typed square brackets [ ] in your expression for Phat:

LucMeekes_1-1678300989030.png

You should NEVER type square brackets, unless you want to create an array.

Change those square brackets to (ordinary) round brackets.

LucMeekes_2-1678301085759.png

Prime will/may show square brackets if necessary (in this  particular case it will not), but that doesn't matter.

 

Success!
Luc