• Post Reply Bookmark Topic Watch Topic
  • New Topic

Copy Array in special format  RSS feed

 
nvayin agha
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Iam trying to produce a structure of array which is repeated.

in matlab repmat() ; will produce a copy of array in specific structure. for example :



k(:,:,2) =

100 0 0
0 100 0
0 0 100
100 0 0
0 100 0
0 0 100


k(:,:,3) =

100 0 0
0 100 0
0 0 100
100 0 0
0 100 0
0 0 100

[/code]

i tried the java code bellow :



the format that iam trying to implement is explained above in matlab

but did not produce same format in java ?

kindly please need some help.

Kind Regards
 
Liutauras Vilda
Sheriff
Posts: 4928
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Always use code tags. In a post editing panel there is a button "Code" which produces 2 code tags. You need to suround your code with those. Usually code looks the way better, unfortunately not in your case, as the code formatting and indentation are not quite right.

Please indent your code snippet so everyone could understand what is in there and re-post it (using code tags). Thank you.
 
Carey Brown
Saloon Keeper
Posts: 3329
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nvayin agha wrote:but did not produce same format ?

What did it produce? What were you expecting? What was your input matrix?

And, please indent you code properly and re-post.
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for adding code tags but your indentation is still all over the place making it hard for us (and for you) to read. Also you have used two different formatting styles (positions of curly braces) in the two sections of code you have shown, please choose one style and stick to it.

Please post your code again (rather than editing the original post) and this time add format it correctly and consistently.

 
nvayin agha
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Iam trying to produce a structure of array which is repeated.

in matlab repmat() ; will produce a copy of array in specific structure. for example :

repmat(arr,2,1,2) : arr = [6,3,9,0];

L(:,:,1) =

6 3 9 0
6 3 9 0


L(:,:,2) =

6 3 9 0
6 3 9 0



the java code bellow :





The format that iam trying to implement is explained above in matlab

the result in java is :


kindly please need some help.

Kind Regards
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure I fully understand what the MatLab repmat method does when you pass in an array with the parameters 2,1,2. Is the second parameter (which you are calling 'columns') the actual number of columns to output or the number of times to repeat the array in the column axis?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!