Entering a group of numbers sequentially in specific positions in a matrix using Matlab - matlab

I have a matrix and I want to enter a group of numbers in this matrix sequentially. Here is an example:
Suppose that:
x = [1 2 3 4 5 6 7] % Group of numbers
A = % The matrix
1.1 2.2 3.1 4.1 5.3 1.2 1.3
3.1 4.2 1.1 7.4 5.6 2.2 1.3
1.4 5.2 4.3 2.2 4.3 3.2 1.3
1.6 3.2 6.3 2.1 2.6 7.2 1.3
6.1 1.3 9.4 4.2 3.3 1.2 1.3
2.5 4.2 3.2 5.1 6.7 1.2 1.3
What I am trying to do is to find a way using loops to enter the group of numbers stored in x to be in the following way:
A = % The matrix
1.1 2.2 3.1 4.1 5.3 1.2 1.3 1.1 2.2 3.1 4.1 5.3 1.2 1.3 1.1 2.2 3.1 4.1 5.3 1.2 1.3
1.0 2.0 3.0 4.0 5.0 6.0 7.0 3.1 4.2 1.1 7.4 5.6 2.2 1.3 3.1 4.2 1.1 7.4 5.6 2.2 1.3
1.4 5.2 4.3 2.2 4.3 3.2 1.3 1.0 2.0 3.0 4.0 5.0 6.0 7.0 1.4 5.2 4.3 2.2 4.3 3.2 1.3
1.6 3.2 6.3 2.1 2.6 7.2 1.3 1.6 3.2 6.3 2.1 2.6 7.2 1.3 1.0 2.0 3.0 4.0 5.0 6.0 7.0
6.1 1.3 9.4 4.2 3.3 1.2 1.3 6.1 1.3 9.4 4.2 3.3 1.2 1.3 6.1 1.3 9.4 4.2 3.3 1.2 1.3
2.5 4.2 3.2 5.1 6.7 1.2 1.3 2.5 4.2 3.2 5.1 6.7 1.2 1.3 2.5 4.2 3.2 5.1 6.7 1.2 1.3
As you can notice the group of numbers (from 1.0 to 7.0) moves down (row by row) till the end of the matrix. At each move the matrix dimension increases as well. I believe that I should define the matrix dimension first.
To do so, I found that multiplying the matrix columns by the number of rows
I will get the new matrix dimension which in this case will be 7 (rows) x 49 (columns).
I need to know how to create such a matrix automatically using for loop or any other possible way.
Thanks in advance.

Use repmat in order to concat 3 copies of your matrix horizontally.
Use the Matlab's assignment syntax: A(row,col:col+length(x)-1) in order to copy x into the desired row and col.
Code example:
outA = repmat(A,1,3); %replicate A
outA(2,1:length(x)) = x; %inserts x into the beginning of the 2nd row
outA(4,size(outA,2)-length(x)+1:end) = x; %inserts x into the end of the 4th row
Results:
outA =
1.1 2.2 3.1 4.1 5.3 1.2 1.3 1.1 2.2 3.1 4.1 5.3 1.2 1.3 1.1 2.2 3.1 4.1 5.3 1.2 1.3
1.0 2.0 3.0 4.0 5.0 6.0 7.0 3.1 4.2 1.1 7.4 5.6 2.2 1.3 3.1 4.2 1.1 7.4 5.6 2.2 1.3
1.4 5.2 4.3 2.2 4.3 3.2 1.3 1.4 5.2 4.3 2.2 4.3 3.2 1.3 1.4 5.2 4.3 2.2 4.3 3.2 1.3
1.6 3.2 6.3 2.1 2.6 7.2 1.3 1.6 3.2 6.3 2.1 2.6 7.2 1.3 1.0 2.0 3.0 4.0 5.0 6.0 7.0
6.1 1.3 9.4 4.2 3.3 1.2 1.3 6.1 1.3 9.4 4.2 3.3 1.2 1.3 6.1 1.3 9.4 4.2 3.3 1.2 1.3
2.5 4.2 3.2 5.1 6.7 1.2 1.3 2.5 4.2 3.2 5.1 6.7 1.2 1.3 2.5 4.2 3.2 5.1 6.7 1.2 1.3

Related

Facebook login for Swift 4

I'm trying to install facebook SDK using swift 4 (xcode version 10.1) and it doesn't work. The error says
'SWIFT_VERSION '5.0' is unsupported, supported versions are: 3.0, 4.0, 4.2. (in target 'FacebookCore')'
'SWIFT_VERSION '5.0' is unsupported, supported versions are: 3.0, 4.0, 4.2. (in target 'FacebookLogin')'
Is there any way to fix this problem without upgrading the swift version to 5.0?

Module compiled with Swift 4.0 cannot be imported in Swift 3.2.1

Swift 4.0 modules were fine in Swift 3.2 apps with Xcode 9.0.
But now, with Xcode 9.1, I get:
Module compiled with Swift 4.0 cannot be imported in Swift 3.2.1
Or:
Module compiled with Swift 4.0 cannot be imported in Swift 4.0.1
Swift 4.0 is compatible with Swift 3.2 only.
Swift 4.0.1 is compatible with Swift 3.2.1 only.
So:
you can't mix 4.0 and 3.2.1
you can't mix 4.0.1 and 3.2
you can't mix 4.0 and 4.0.1
you can't mix 3.2.1 and 3.2
To formulate it differently:
you can mix Xcode 9.0 supported Swift versions together
you can mix Xcode 9.1 supported Swift versions together
you can't mix Xcode 9.0 and Xcode 9.1 Swift versions
If the module was built by you, simply rebuild it with the same Xcode.
If the module was built by a third party, request an Xcode 9.1 compatible build.
It's possible to build using Swift 3.2 in Xcode 9.1 beta 2 by installing the Xcode 9.0 toolchain and using that to build your project.
Then choose the Swift 4.0 release under the Xcode -> Toolchains menu.
You should now be able to build with either Swift 3.2 or 4.0 in Xcode 9.1 b2.
Using the last Xcode version solved this issue

How to upgrade SonarQube from 5.1 to 6.2

What is the exact path to a migration from sonarqube 5.1 to 6.2
Can i upgrade from 5.1 to 5.6.3 to 6.2?
I would upgrade using the last fix of 5.6
5.1 -> 5.6.6 -> 6.2
but the db upgrade should work also with the migration path you suggested.
Anyway, because 6.3.1 fixes some issues of 6.2, I would upgrade
5.1 -> 5.6.6 -> 6.3.1

multiple knitr kables by group

for a given dataset, I want to print group-wise kables with group names as caption in an rmarkdown.
say this is my_document:
library(magrittr)
library(dplyr)
library(knitr)
iris %>%
group_by(Species) %>%
slice(1:10) %>%
do(kables = kable(., caption = .$Species[1])) %$%
kables %>%
lapply(print)
i call rmarkdown::render("my_document.R") to generate the markdown output.
the problem now is that my kables appear in comments, but not as rendered kables:
## Table: setosa
##
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## ------------- ------------ ------------- ------------ --------
## 5.1 3.5 1.4 0.2 setosa
## 4.9 3.0 1.4 0.2 setosa
## 4.7 3.2 1.3 0.2 setosa
## 4.6 3.1 1.5 0.2 setosa
## 5.0 3.6 1.4 0.2 setosa
## 5.4 3.9 1.7 0.4 setosa
## 4.6 3.4 1.4 0.3 setosa
## 5.0 3.4 1.5 0.2 setosa
## 4.4 2.9 1.4 0.2 setosa
## 4.9 3.1 1.5 0.1 setosa
##
##
## Table: versicolor
##
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## ------------- ------------ ------------- ------------ -----------
## 7.0 3.2 4.7 1.4 versicolor
## 6.4 3.2 4.5 1.5 versicolor
## 6.9 3.1 4.9 1.5 versicolor
## 5.5 2.3 4.0 1.3 versicolor
## 6.5 2.8 4.6 1.5 versicolor
## 5.7 2.8 4.5 1.3 versicolor
## 6.3 3.3 4.7 1.6 versicolor
## 4.9 2.4 3.3 1.0 versicolor
## 6.6 2.9 4.6 1.3 versicolor
## 5.2 2.7 3.9 1.4 versicolor
##
##
## Table: virginica
##
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## ------------- ------------ ------------- ------------ ----------
## 6.3 3.3 6.0 2.5 virginica
## 5.8 2.7 5.1 1.9 virginica
## 7.1 3.0 5.9 2.1 virginica
## 6.3 2.9 5.6 1.8 virginica
## 6.5 3.0 5.8 2.2 virginica
## 7.6 3.0 6.6 2.1 virginica
## 4.9 2.5 4.5 1.7 virginica
## 7.3 2.9 6.3 1.8 virginica
## 6.7 2.5 5.8 1.8 virginica
## 7.2 3.6 6.1 2.5 virginica
so how do i get rendered kables by group in my markdown document?
You need to specify results="asis" in the chunk options. Have a read of http://yihui.name/knitr/options/#chunk_options as you may also want to use echo=FALSE to hide your code and/or message=FALSE to hide any messages that arise from loading packages.
E.g., if I don't specify message=FALSE I get:
Attaching package: ‘dplyr’
The following object is masked from ‘package:stats’:
filter
The following objects are masked from ‘package:base’:
intersect, setdiff, setequal, union
in the final output after loading dplyr.

How to develop for iPhone OS 3.1.2?

Strange thing happened: My old 2.2.1 version iPod works perfectly with Xcode. Now I got a new one with 3.1.2 installed. Xcode complains that it can't develop for 3.1.2, but instead it can do so for:
Xcode Supported iPhone OS Versions
3.1.1 (7C145)
3.1 (7C144)
3.0.1 (7A400)
3.0
2.2.1
2.2
2.1.1
2.1
2.0.2 (5C1)
2.0.1 (5B108)
2.0 (5A347)
2.0 (5A345)
Now what can I do about it? I have Snow Leopard and Xcode 3.2
You have to update your version of XCode. Go to http://developer.apple.com/iphone/ and download the new SDK.
Sounds like you need the new iphone SDK 3.2 beta available from developer.apple.com today.