Posts

Showing posts from January, 2015

c - How do I handle ruby arrays in ruby ffi gem? -

i want use ruby ffi gem call c function has array input variable , output array. is, c function looks like: double *my_function(double array[], int size) i have created ruby binding as: module mymodule extend ffi::library ffi_lib 'c' ffi_lib 'my_c_lib' attach_function :my_function, [:pointer, int], :pointer i make call in ruby code like: result_array = mymodule.my_function([4, 6, 4], 3) how go this? let's library wish use in ruby script, call my_c_lib.c : #include <stdlib.h> double *my_function(double array[], int size) { int = 0; double *new_array = malloc(sizeof(double) * size); (i = 0; < size; i++) { new_array[i] = array[i] * 2; } return new_array; } you can compile so: $ gcc -wall -c my_c_lib.c -o my_c_lib.o $ gcc -shared -o my_c_lib.so my_c_lib.o now, it's ready use in in ruby code ( my_c_lib.rb ): require 'ffi' module mymodule extend ffi::library # assuming library files in s

changing field in a set object in mongodb -

i have document in mongo: { id: objectid, list: [ { id: internalobjectid1, enabled: true }, { id: internalobjectid2, enabled: false }] } i need change enabled field. how can it? use positional $ operator . suppose have following document in collection list element value array of embedded documents: { "_id" : objectid("551be1a04db8a16ac729432e"), "list" : [ { "id" : objectid("54f43159c922ac0b4387ef9c"), "enabled" : true }, { "id" : objectid("54f43159c922ac0b4387ef9d"), "enabled" : false } ] } the following update value of enabled field in embedded document id of 54f43159c922ac0b4387ef9d true : db.collection.update( { "_id": objectid("551be1a04db8a16ac729432e"), "list.id": ob

How to limit the depth of the @Fetch annotation in Spring data neo4j -

i know @fetch annotation can used load nodes on other sides of relationships . normally, appears id of foreign node loaded, , not properties. is there way limit depth of @fetch first neighbor loaded, , no further? in heavily connected graph, don't want load entire graph of course, minimize number of calls server, it's useful first level of connected nodes included in response. currently there no way of limiting depth, @fetch goes along next object , if 1 has again @fetch annotations continue load. might not have been wisest decision so, that's way in sdn3. in sdn4 have option specify depth parameter load , store methods. i'm not big fan of navigation / loading of nested structures via domain objects. that's why i'd rather recommend nested loading write use-case specific cypher query load data need , project dto annotated @queryresult part of repository method. interface movierespository extends graphrepository<movie> { @quer

php - PDO fetchAll Results returns only one record issue -

i have developed following script in localhost (using wamp 2.2, apache 2.2.1 windows, php 5.3.9, mysql 5.5.20). when upload script production server (apache 2.2.29 unix, php 5.3.29, mysql 5.5.42) i noticed php+pdo script did not return fetched rows in same way same script in local server. if try add "order by" sql instance, works on local in production server resulted fetched row same. also tryed change inner join table order same result. clues? maybe wrong inner join php + pdo: $user = ''; $pass = ''; $dsn = 'mysql:host=myhost;dbname=mydbname;charset=utf8'; try { $pdo = new pdo($dsn, $user, $pass); $pdo->setattribute(pdo::attr_errmode, pdo::errmode_exception); } catch (pdoexception $e) { echo 'error: ' . $e->getmessage(); } function contents($id) { global $pdo; $stmt = $pdo->prepare('select historia.id idhistoria, pub_us.comic, pub_us.id historia inner join pub_us on pub_us.historia = histor

css - How to deactivate compressing in grunt less? -

the grunt-contrib-less package provides option compress , should allow managing uglifying/minifying/compression of destination css file. boolean default value false . for reason woesn't work me -- whatever set parameter to, output css file compressed. ho working correctly? gruntfile.js module.exports = function(grunt) { // project configuration. grunt.initconfig({ pkg: grunt.file.readjson('package.json'), less: { development: { options: { paths: ["public/css"], compress: false }, files: { "public/css/style.css": "public/css/style.less" } }, production: { options: { paths: ["public/css"], compress: false, plugins: [ new (require('less-plugin-autoprefix'))({browsers: ["last 2 versions"]}), new (require('less-plugin-clean-css'))([]) ],

java - JUnit Mockito Request and Response -

i trying create test login page using junit need mock out dev controller. as used httpservlet in dev environment, testing environment asking httprequest... i went mock request file not getting i'm using controller not servlet. can me on this? below junit controller package com.atoc.test.controller; import java.io.printwriter; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import org.junit.before; import org.junit.test; import org.junit.runner.runwith; import org.mockito.injectmocks; import org.mockito.mock; import org.mockito.mockito; import org.mockito.mockitoannotations; import org.springframework.mock.web.mockhttpservletrequest; import org.springframework.mock.web.mockhttpservletresponse; import org.springframework.test.context.contextconfiguration; import org.springframework.test.context.junit4.springjunit4classrunner; import org.springframework.test.context.web.webappconfiguration; import org.springframework.test.w

c# - Why won't my JavaScript work in a ASP.net web form? -

i have no problems running code html page. now, in web form, converter nothing. trying migrate on web form page html use master page , theme. <asp:content id="content1" contentplaceholderid="head" runat="server"> <script lang="javascript" type="text/javascript"> //convert logic function celsiusconvert() { document.converter.fahrenheit.value = (document.converter.celsius.value * 9 / 5) + 32 document.converter.kelvin.value = document.converter.celsius.value * 1 + 273.15 } function fahrenheitconvert() { document.converter.celsius.value = (document.converter.fahrenheit.value - 32) * 5 / 9 document.converter.kelvin.value = ((document.converter.fahrenheit.value - 32) * 5 / 9) + 273.15 } function kelvinconvert() { document.converter.celsius.value = document.converter.kelvin.value - 273.15 document.converter.fahrenheit.value = ((document.converter.kelvi

ios - Apple Watch app installation issue - NSExtensionPointIdentifier -

i'm trying install app watchkit app , watchkit extension onto ios8.1 phone, xcode 6.2. i have deployment target set @ 8.1 , base sdk @ 8.2. i error: this app contains app extension specifies extension point identifier not supported on version of ios value of nsextensionpointidentifier key in info.plist i've seen similar questions not found solution works. there way programmatically handle lower ios version? to answer (using @lovo's comment) - fixed issue changing deployment target 8.2 in extension's build settings (not in main app's build settings). the main app's deployment target can set @ lower deployment target, mine 7.0.

google cloud messaging - Android quickblox how to receive message if user is not in chat room -

i working on chat application using quickblox sdk . private , public chat working fine, user receives message group , in 1 one chat. my problem showing friends , groups list user has joined. want show notification if user received message group or private chat (the user has not opened chat room). push notification messages not being received in screen, received when close app or logout. there way in quickblox show message notification if user not in chat room logged in? for private group chats push notifications sent if not in room (didn't join). another way join rooms @ start app, able receive messages group chat in realtime

Fast App resume not working under password lock screen on windows phone 8 -

i have implemented fast resume in windows phone 8 app , working fine in every case except following scenario. steps: 1)phone password locked 2)toast received. 3)tap on toast. 4)app activated. 5)the page last on backstack opens reset state. 6)no more navigation in fast resume app should receive 1 more navigation deep link on tapping on toast missing in case. please find sample here . this feature of windows phone. if reminder or toast send lock screen (even without password), navigation application limited. think there no way fix behavior ... i got more unpleasant situation reminders of applications: 1) if screen not locked , gave reminder of application, click on reminder open application, can take action in response reminder. , good. 2) when lock screen (even without password) , send reminder of application, there no ability navigate application clicking reminder. reminder, can cancel or postpone while. user must unlock screen, open program , try u

c - String length Error -

i reading string stdin using fgets function , trying print length of string, getting length of string 1 first time here code #incldue<stdio.h> #include<string.h> int main(void) { printf("\n enter no of test cases"); scanf("%d",&t); int i,j; for(i=0;i<t;++i) { char song[500],val[28]; int k=0,x=0; fgets(song,500,stdin); int len=strlen(song); printf("\nlen=%d",len); } return 0; } i getting 1 length first test case :/ please suggest going wrong you not clearing input buffer. after giving input value first scanf newline there. fgets not input user. newline placed in buffer in first( song[0] ) position. reason strlen returns value 1 . make line before fgets . int c; if ( == 0 ) while((c=getchar()) != '\n' && c != eof ); fgets(song,500,stdin); or else place line after getting input scanf . scanf("%d",&t); while((c=getchar()) != '\n&#

java - Spring Data MongoDB: how to implement multi-tenancy in CrudRepository -

this question has answer here: making spring-data-mongodb multi-tenant 2 answers i designed db support multi-tenancy: every document has reference tenant . i'm using spring data mongodb implement data access logic , need handle document retrieval tenant in repositories. is there common approach implement it? need override every method of crudrepository match documents tenant or there facilities achieve this? i decided implement multi-tenancy @ service layer suggested markus w mahlberg in comment. at repository level created findbytenantidandid query check if entity/document id belongs proper tenant. i have custom implementation of userdetails interface, storing tenantid logged user. retrieve logged user @ service layer via securitycontextholder .

Tomcat web app with ActiveMQ broker over TCP -

i trying set activemq broker within context of web app hosted in tomcat. additionally, connector want use tcp broker should accessible remote applications. so far, have done create simple web app local jndi context.xml configuration following: <resource auth="container" name="jms/connectionfactory" type="org.apache.activemq.activemqconnectionfactory" description="jmsconnection" factory="org.apache.activemq.jndi.jndireferencefactory" brokerurl="tcp://localhost:61616" brokername="mqbroker"/> <resource auth="container" name="jms/mqueue" type="org.apache.activemq.command.activemqqueue" description="jms queue" factory="org.apache.activemq.jndi.jndireferencefactory" physicalname="some.queue"/> i have updated web.xml file accordingly , called connection factory servletcontextlistener implementing

javascript - PHP: getting variables for many rows in a databse -

i trying send php variable id thats saved in database page displaying google map markers using javascript. have created list display displayed when map marker clicked in php/html: $result = mysqli_query($con,"select * places"); while($row = mysqli_fetch_array($result)) { echo "<div class='place-details' id='place-details' style='display: none'>"; echo "<table class='table'>"; echo "<tr><th>name: </th><td>" . $row['name'] . "</td></tr>"; echo "<tr><th>details: </th><td>" . $row['description'] . "</td></tr>"; echo"</table>"; echo "<td><a href='details.php?id=".$row['id']."' class='btn btn-warning btn-sm'>view</a></td>&

c++ - Inline member initializer containing pointer to member -

at work, i'm experimenting bit bring reflection our codebase. want achieve, capture pointer data-member inside type of data-member's initializer: template<class class, int class::*datamember> struct reflect { operator int() {return 0;} }; class foo { public: int bar = reflect<foo, &foo::bar>{}; }; although clang 3.4.1 ( http://gcc.godbolt.org/ ) , intel c++ xe 14.0 able compile piece of code, when using msvc12 following error message: error c2065: 'bar' : undeclared identifier error c2975: 'datamember' : invalid template argument 'reflect', expected compile-time constant expression furthermore, gcc 4.9.2 seems have trouble it: http://ideone.com/zuvomo . so questions are: is above piece of code valid c++11? if yes, there work arounds failing compilers? what vc++ complains not problem; [basic.scope.pdecl]/1,6: the point of declaration name after complete declarator (clause 8) and before

java - Config SLF4J in jar file -

i have own jar file used library main application. need set slf4j logger , configure in jar. write logs file set other configurations in property file when googled, there samples web apps. 1 let me know how above functionalities or mention useful resource. for library, should include slf4j-api.jar . means in code, should use classes within slf4j's api, i.e. loggerfactory , logger . your library should not define else regarding logging. it's responsibility of application uses library define underlying logging implementation (logback, log4j, jcl, etc) , include necessary bindings , underlying logging platform's configuration, such logback.xml file. please refer slf4j manual further reference.

c++ segmentation fault for dynamic arrays -

i want add theater object boxoffice object in c++ code. when try add in main code, first 1 added successfully. segmentation fault occurs second , obvioulsy other theater objects. here add function; #include <iostream> #include <string> #include "boxoffice.h" using namespace std; boxoffice::boxoffice() { sizereserv = 0; sizetheater = 0; theaters = new theater[sizetheater]; reserv = new reservation[sizereserv]; } boxoffice::~boxoffice(){} void boxoffice::addtheater(int theaterid, string moviename, int numrows, int numseatsperrow){ bool theaterexist = false; for(int i=0; i<sizetheater; i++) { if(theaters[i].id == theaterid) { theaterexist=true; } } if(theaterexist) cout<<"theater "<<theaterid<<"("<<moviename<<") exists"<< endl; else { ++sizetheater; theater *temptheater = new theate

javascript - Dijkstra's algorithm on three dimensional array -

Image
i cannot figure out how implement in psuedo-code. user enters in this: [ [ [0,1] ], [ [5,6],[7,8] ], [ [91,17],[18,42] ], [ [20,54] ] ] basically path [0,1] maps ([5,6] , [7,8]) each of maps ([91,17] , [18,42]) , on, cost distance between points. starting point [0, 1] , ending point [20,54]. there 1 starting point , 1 ending point, , points in previous index map points in next index. how implement dijkstra's algorithm kind of data structure? this image may (not scale): green start , red end. notice given array 2 dimensional if considered entry in array pair (x, y) . the basic idea build graph, assign cost of edges, , apply standard dijkstra's algorithm. building graph: make 2 hash tables h , q h([x,y]) maps vertex (x,y) number between 0 , n - 1 , , q maps integer between 0 , n - 1 vertex (x, y) . n number of vertices in graph. can find n looping on vertices in given 2d array. let's call given array a

python - Pandas: Adding conditionally -

i have data frame set of columns, on want perform conditional operation follows: foo = 0 * foobar2['var1'] foo.loc[foobar2['var1'] > 0] += foobar2.loc[foobar2['var1'] > 0, 'var1'] foo.loc[foobar2['var2'] > 0] += foobar2.loc[foobar2['var2'] > 0, 'var2'] foo.loc[foobar2['var3'] > 0] -= foobar2.loc[foobar2['var3'] > 0, 'var3'] foo.loc[foobar2['var4'] > 0] -= foobar2.loc[foobar2['var4'] > 0, 'var4'] that is, want sum var1 , var2 , , subtract var3 , var4 - whenever these variables positive, negative variables indicate missing values , similar in data set. code works, quite slow. there more efficient way this? this approach fastest have tried: foo = foobar2.clip_lower(0) foo = foo['var1']+foo['var2']-foo['var3']-foo['var4'] this approach tiny bit little slower: foo = foobar2.clip_lower(0) foo['var3']*=-

javascript - float's not returing to position after mobile view end -

on menu when in mobile view not float correct. problem being when come out of mobile view class "menu-right" floats left until reload page. is possible when comes out of mobile view "menu-right" class automatically go float right out me reloading page. i not sure if it's css or java script. live code example: http://codepen.io/riwakawebsitedesigns/pen/ggljml live code full view: http://codepen.io/riwakawebsitedesigns/full/ggljml/ java script var ww = document.body.clientwidth; $(document).ready(function() { $("#menu li a").each(function() { if ($(this).next().length > 0) { $(this).addclass("parent"); }; }) $(".menu-toggle").click(function(e) { e.preventdefault(); $(this).toggleclass("menu-button"); $("#menu").toggle(); }); adjustmenu(); }) $(window).bind('resize orientationchange', function() { ww = documen

php - Laravel query subquery -

for example have 2 queries: 1: $q = somecontent::select('somecontent_id') ->where('slug', request::segment(2)) ->where('something', $something) ->first(); 2 $req = somecontent::select('slug') ->where('something', $anothersomething) ->where('somecontent_id', $q->somecontent_id) ->first(); how merge these 1 query if possible in laravel's query builder? can't find lot using selects statements inside statements. you can union them together, like // query builder provides quick way "union" 2 queries together: $q = somecontent::select('somecontent_id') ->where('slug', request::segment(2)) ->where('something', $something); $req = somecontent::select('slug') ->where('something', $anothersomething) ->where('somecontent_id', $q->somecontent_id) ->union($q)->get();

iterate over result pages using selenium and python: StaleElementReferenceException -

i think people understood selenium tool laugh maybe can share you're knowledge because want laugh now, too. my code this: def getzooverlinks(country): global countries countries = country zooverweb = "http://www.zoover.nl/" url = zooverweb + country driver = webdriver.firefox() driver.get(url) button = driver.find_element_by_class_name('next') links = [] page in xrange(1,4): webdriverwait(driver, 60).until(lambda driver :driver.find_element_by_class_name('next')) divlist = driver.find_elements_by_class_name('blue2') div in divlist: hreftag = div.find_element_by_css_selector('a').get_attribute('href') print(hreftag) newlink = zooverweb + hreftag links.append(newlink) button.click() driver.implicitly_wait(10) time.sleep(60) return links so want iterate on result pages , link

matlab - Different results between a mex file and C file -

i have matlab code in computationally expensive part converted c mex file. mex file is: /* copyright henrik stewenius*/ /************************************************* indata : 9x4 matrix data out: 10x20 matrix *************************************************/ #include "mex.h" #include <math.h> void mexfunction(int nlhs, mxarray *plhs[], int nrhs, const mxarray *prhs[]) /*nlhs number of expected mxarrays. plhs pointer array of null pointers. nrhs number of input mxarrays. prhs pointer array of input mxarrays. */ { double *ee, *a; double e00,e01,e02,e03,e04,e05,e06,e07,e08; double e10,e11,e12,e13,e14,e15,e16,e17,e18; double e20,e21,e22,e23,e24,e25,e26,e27,e28; double e30,e31,e32,e33,e34,e35,e36,e37,e38; double e002,e012,e022,e032,e042,e052,e062,e072,e082; double e102,e112,e122,e132,e142,e152,e162,e172,e182; double e202,e212,e222,e232,e242,e252,e262,e272,e282; double e302,e312,e322,e332,e342,e3

javascript - get text of clicked a tag element with siblings -

i trying text on <a> element shown in plunker, first click shows text string correctly, if click again shows twice , thrice next, not sure how prevent it. ?? thanks in advance http://plnkr.co/edit/efnfsdu1lkw8jvnzk4zz?p=preview if use angular don't need use jquery events, can pass $event function , text current target, so $scope.getword = function ($event) { alert(angular.element($event.target).text()); } <a class="refer-word" ng-click="getword($event)">javascript</a> <a class="refer-word" ng-click="getword($event)" name ="client">client</a> example

angularjs - How to resolve promises of child controller on route change? -

i have angular ionic app. assigned controller, template , resolve promises in routes. working fine main controller loads after promises of parent controller resolved. if route contains child controller promises. here problem page need load after promises of parent , child controller resolved. punker var app = angular.module('testapp', ['ionic']); app.config(function($stateprovider, $urlrouterprovider) { $stateprovider.state('dashboard', { url: "/dashboard", templateurl: "dashboard.html", controller: 'dashboardcontroller', title: 'dashboard', resolve: { userdetails: function(dataservice) { return dataservice.getuserdetails(1); }, dashboarddetails: function(dataservice) { return dataservice.getdashboarddetails(); } } }); $urlrouterprovider.otherwise('/dashboard'); }); app.factory('dataservice'

java - RabbitMQ messages shoing error : TypeError: queue.backing_queue_status is undefined ReferenceError: queue is not defined -

i working on java application communicates rabbitmq server. yesterday of message queues started behaving strangely. see nothing showing in following fields weird queues: policy , state and in fields "ready","unacked","toatal" see "?". while clicking on queues see following error message : typeerror: queue.backing_queue_status undefined referenceerror: queue not defined the biggest problem application dependent upon rabbutmq server. have separate thread running fetches details queues , job. moment tries fetch properties corrupted queues looks thread dies. not see exception . whole workflow stops. please me out. my application specifications : language : java framework : spring 3.x rabbitmq version : 3.3.1 framework used access rabbitmq : spring-rabbit-1.2.1

shell - basic Unix command not found -

i've installed mysql on laptop. now when launch terminal window , unix command grep , message: -bash: grep: command not found -bash: cat: command not found ... what's happen ? have skills or ideas retrieve precious unix functions ? i'd put in comment, don't have enough reputation, sorry! basic unix commands grep or cat in folder: /usr/bin in order them work, need have correct set of path variable. might have changed unknowingly during installation of mysql. can fix temporarily trying like: export path=$path:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin this add whatever have on path @ moment, "normal" routes precious unix functions. try commands again after executing line in terminal, , let know :)

css - dynamically position element with Less -

i have div (div1) shows on hover of div (div2) right , bottom of (sort of tool tip). when div2 happens close bottom of screen, div1 goes off screen (completely or partially). there way position div1 top of div2 depending on div2 located , purely less, no javascript. maybe other ways, without javascript. thank you. with pure css not possible @ current moment. still can without javascript. ugly , not reliable. consider next line more sport interest actual advice. can achieve so: determine on server side how space there between div2 , end of html content. make sure data client device can (like width , height) somehow user agent , consider them in calculation. calculate sizes of div1. bit easier, think. generate appropriate css

security - The stack is executable, but should not? -

my issue simple explain ! a vulnerable program able execute shellcode in stack : (with gdb) 0xbffff6f3: push ... => 0xbffff6f8: jns ... but, stack marked not executable : (vmmap) ... b7fff000-b8000000 rw-p 0001c000 08:01 525141 /lib/i386-linux-gnu/ld-2.13.so bffdf000-c0000000 rw-p 00000000 00:00 0 [stack] how can possible ? don't know look. have idea ? thank you. jc ! may can useful : jc@kali:~/init$ uname -a linux kali 3.18.0-kali1-586 #1 debian 3.18.3-1~kali4 (2015-01-22) i686 gnu/linux jc@kali:~/init$ gcc -v using built-in specs. collect_gcc=gcc collect_lto_wrapper=/usr/lib/gcc/i486-linux-gnu/4.7/lto-wrapper target: i486-linux-gnu configured with: ../src/configure -v --with-pkgversion='debian 4.7.2-5' --with-bugurl=file:///usr/share/doc/gcc-4.7/readme.bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --w

android - AsyncTask Cannot execute task: the task has already been executed -

i know previous execution of asynctask running - question how finish , re-execute , because parameters has been changed. protected class imagedownloadtask extends asynctask<response, void, void>{ @override protected void onpreexecute() { super.onpreexecute(); pooltasks.add(this); } @override protected void doinbackground(response... params) { int count=params[0].getgetposts().getpostscount(); for(int = 0; < count; i++){ post post = params[0].getgetposts().getposts(i); if(!iscancelled()){ try { //some code download images } catch (exception e) { } publishprogress(); } else pooltasks.remove(this); } return null; } @override protected void onpro

proc - Two Way Transpose SAS Table -

i trying create 2 way transposed table. original table have looks like id cc 1 2 1 5 1 40 2 55 2 2 2 130 2 177 3 20 3 55 3 40 4 30 4 100 i trying create table looks like cc cc1 cc2… …cc177 1 264 5 0 2 0 132 6 … … 177 2 1 692 in other words, how many id have cc1 have cc2..cc177..etc the number under id not count; id range 3 digits 5 digits id or numbers such 122345ab78 is possible have percentage display next each other? cc cc1 % cc2 %… …cc177 1 264 100% 5 1.9% 0 2 0 132 6 … … 177 2 1 692 if want change cc1 cc2 characters, how modify arrays? eventually, table looks like cc dell lenovo hp sony dell lenovo hp sony the order of names must match cc numbe

http - Get real client IP in OpenShift? -

i tried an application , , used way ban send more 5 empty requests server, problem then, got blocked, , because seen 1 unique ip. in code , used way x-real-ip doesent work on openshift, how then? here how ip: x_real_ip = self.request.headers.get("x-real-ip") remote_ip = self.request.remote_ip if not x_real_ip else x_real_ip update: '127.3.165.129', none) when doing print(self.request.remote_ip, x_real_ip) you want "x-forwarded-for" header visitors ip address. seeing ip address of reverse proxy users go through before ending @ application/gear. you can refer article in developer center more information how requests routed on openshift: https://developers.openshift.com/en/managing-port-binding-routing.html

Split Matrix into several depending on value matlab -

i trying split nx3 matrix submatrices in matlab. matrix c of shape c = 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 it either has rows of zeros or rows of ones. want split matrix keep matrices of ones. here instance there's 3 'groups' of ones. want get c1 = 1 1 1 c2 = 1 1 1 1 1 1 1 1 1 c3 = 1 1 1 1 1 1 however real matrix n 3, don't know ones are. edit 1: now, need split x1 , y1 (individual row vectors same length c ) x(1), x(2),.. (similarly y vector) based on how matrix c split sample input: x1 = (1:9)'; y1 = (2:2:18)'; desired output: x(1)=[1], x(2)=[4 5 6]' , x(3)=[8 9]' y(1)=[2], y(2) =[8 10 12]' , y(3)=[16 18]' input: c = [1 1 1; 0 0 0; 0 0 0; 1 1 1; 1 1 1; 1 1 1; 0 0 0;