Finding Null space of a large sparse matrix in MATLAB 
I guess you can try with some sort of decomposition.
http://www.mathworks.co.uk/matlabcentral/fileexchange/11120nullspaceofasparsematrix
Have you tried this?
Or maybe this?
http://www.mathworks.co.uk/matlabcentral/newsreader/view_thread/249467
I am confident they should work, but I have not tried them myself. Another
way of proceeding would be to get into QR decomposition (which would give
you the permutation of the first k independent columns, if k is the rank of
your matrix. Then the vectors from k+1 to n would provide a basis for your
null space).
Hope this helps.
Cheers,
GL

Transformation 2 input 2 output transfer function into state space model using MATLAB 
Converting to a SS model is always an ugly process, and depending on the
method you can get different representation. So don't obsess over getting
equal values of A B C and D.
Also, the states of SS that have been converted from TF often have no
meaning other the storing information of the previous state.
To verify whether you have similar SS system, throw in an impulse response:
impulse (sys, sysSimulink)
From the documentation:
Recommended Working Representation
You can represent numeric system components using any model type.
However, Numeric LTI model types are not equally wellsuited for
numerical computations. In general, it is recommended that you work
with statespace (ss) or frequency response data (frd) models, for the
following reasons:
The accuracy of

octave/matlab: create new matrix based on existence of words from one matrix in another 
Easily with a forloop:
new = cell(size(all));
for v=1:length(all)
if any(strcmp(some,all{v}))
new{v}=1;
else
new{v}=0;
end
end
Alternatively, you could use intersect:
[isect, index_all, index_some]=intersect(all,some);
If you don't need your new values to be a cell (for zero or one, there's no
reason not to use a simple array), then this is easy:
new=zeros(size(all));
new(index_all)=1;
If you need them to be a cell for some reason, then use:
new=num2cell(new);
PS: you should't use all as a variable name  it is an inbuilt Matlab
function, and by overwriting it with a variable, you cannot use it until
you clear the variable.

Changing values in one MatLab matrix based on ranges stored in a second matrix 
How about replacing everything with:
vals = sparse(triggerIndices, 1, increment, numel(sourceData), 1);
vals(triggerIndices(1)) = addOn;
sourceData(:) = sourceData(:) + cumsum(vals);
This is basically a variant of runlength decoding shown here.

sparse matrix parallel to the full matrix syntax of A(ind,ind)=1 in Matlab 
You can use the sparse command, as follows:
% create a 5x5 sparse matrix A, with 1's at A(ind,ind)
[row,col] = meshgrid(ind,ind); % form indexing combinations
row = row(:); % rearrange matrices to column vectors
col = col(:);
A = sparse(row, col, 1, 5, 5);
While it is possible to index sparse matrices using the conventional A(1,2)
= 1 style, generally this is not a good idea. MATLAB sparse matrices are
stored very differently to full matrices behind the scenes and do not
support efficient dynamic indexing of this kind.
To get good performance sparse matrices should be built in one go using the
sparse(i,j,x,m,n) syntax.

MATLAB  matrix multiply submatrices within a single matrix 
I think you have to reshape your matrix in different way to do the
vectorized multiplication, like in the code below. This code also uses
loop, but I think should be faster
MM = magic(2);
M0 = MM;
M1 = rot90(MM,1);
M2 = rot90(MM,2);
M3 = rot90(MM,3);
MBig1 = cat(2,M0,M1,M2,M3);
fprintf('Original matrix
')
disp(MBig1)
MBig2 = zeros(size(MBig1,2));
MBig2(1:2,:) = MBig1;
for k=0:3
c1 = k *2+1;
c2 = (k+1)*2+0;
MBig2(:,c1:c2) = circshift(MBig2(:,c1:c2),[2*k 0]);
end
fprintf('Reshaped original matrix
')
disp(MBig2)
fprintf('Checking [ M0*M0 M0*M1 M0*M2 M0*M3 ] in direct way
')
disp([ M0*M0 M0*M1 M0*M2 M0*M3 ])
fprintf('Checking [ M0*M0 M0*M1 M0*M2 M0*M3 ] in vectorized way
')
disp( kron(eye(4),M0)*MBig2 )
fprintf('Checking [ M0

MATLAB: Matrix containing values of another matrix at specific indices 
You can't do it for randomly generated matrices, because you have to ensure
that matrix A has lines and columns as required from the values of x and y.
In this case, you can write:
for i=1:length(x(:))
B(i)=A(x(i),y(i));
end
B=reshape(B,size(x));

Matlab: Improper index matrix reference (or outsmarting matlab) 
In the latest versions of MATLAB (13a/13b) there's a unit testing framework
built in that looks very similar to what you're attempting. Instead of
expect(myfibonacci(0)).toBe(0);
you would write
import matlab.unittest.constraints.IsEqualTo
testCase.verifyThat(myfibonacci(0), IsEqualTo(0))
(You could also/instead have assumeThat, assertThat, or fatalAssertThat).
If for some reason you wish to implement your own framework, note the small
difference in your syntaxes  you have a dot whereas MathWorks have a comma
between myfibonacci(0) and the test condition.
In MATLAB you can't index into the result of a subscripted expression like
that (well, you could, but you would have to overload subsref, and that's a
world of pain, trust me). So the way they've done it is to introduce the
test

How to parse spaceseparated floats in C++ quickly? 
Before you start, verify that this is the slow part of your application and
get a test harness around it so you can measure improvements.
boost::spirit would be overkill for this in my opinion. Try fscanf
FILE* f = fopen("yourfile");
if (NULL == f) {
printf("Failed to open 'yourfile'");
return;
}
float x,y,z;
int nItemsRead = fscanf(f,"%f %f %f
", &x, &y, &z);
if (3 != nItemsRead) {
printf("Oh dear, items aren't in the right format.
");
return;
}

Regex to match a doubles separated by one space only 
You can use this:
^(?:d+[.]d+(?:[ ]d+[.]d+)*)?$
Explanation:
^
 // Match ''
(?: // An optional noncapturing group
d+[.]d+ // Match pattern  14.45
(?: // A 0 or more times repeating Noncapture group
[ ] // A space
d+[.]d+ // Pattern matching  14.56
)*
)?
$

JQuery Attribute Wildcards Contains space separated 
Use ~ (Attribute contains word) match selector
$('[databindcontains~=HeaderLogo]')
This will give you exact word matched within the attribute value, so this
should exclude yourwordsomething.
Fiddle to demonstrate the difference.
Doc

C read spaceseparated values from file 
Global variables such as pay — clearly defined as FILE *pay; — are a
bad idea, and completely unnecessary in the example code. Always test the
return value from fscanf() and its relatives to ensure that you got all the
data you expected.
However, your trouble is that %s stops at the first space, so you have
immense problems reading the address field. Your inputs are unconstrained
too. You also try to get multiple words of the street address using
e>street multiple times; that won't work since the third word will
overwrite the first.
You need something like:
int inputLine(FILE *fp, Employee* e)
{
if (fscanf(fp, "%7s %c %9s %16c %11c %2s %d %d %c %d %f",
e>first, &e>initial, e>last, e>street,
e>city, e>state,

Regex to match space separated words like CSS classes 
You are probably looking for something like:
(^s)name(s$)
starting at the beginning of the string (^) or after whitespace
ending at the end of the string ($) or before whitespace
See e.g.
http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html

How do I remove the first two words in string which aren't separated by a space? 
text = "Product DescriptionThe Signature Series treatment makes the
strategy guide a COLLECTIBLE ITEM for StarCraft II fans. Singleplayer
CAMPAIGN WALKTHROUGH covers all possible mission branches, including bonus
objectives throughout the campaign. Exclusive MAPS found only in the
official guide, show locations of units,..."
text[/.*.../m].sub(/AProduct Description/, '')
# => "The Signature Series treatment makes the strategy guide a
COLLECTIBLE ITEM for StarCraft II fans. Singleplayer CAMPAIGN WALKTHROUGH
covers all possible mission branches, including bonus objectives throughout
the campaign. Exclusive MAPS found only in the official guide, show
locations of units,..."

Reading space separated values file in c++ error 
This is a problem in the precision of the cout.
Try to test the comparison:
cout << "Stand.: " << a << " Prec.: " << fixed
<< setprecision(10) << a << endl;

Mysql: Search in fields with space separated values 
To find the rows you want you can do something like :
SELECT *
FROM table_name
WHERE concat(' ',status,' ') not like '% sent %'
If status always appears at the end of the field and is always prefixed by
a space
SELECT *
FROM table_name
WHERE status not like '% sent'

How to get user input as a matrix format to perform matrix addition in php? anybody having suggestions? 
The simplest (and possibly most intuitive) way would be to present the user
with a <textarea> and ask them to input the matrix values in the
following format:
a b
c d
Values in individual rows are delimited by spaces, and rows are delimited
by newlines. Here's a quick and easy way to generate a matrix out of the
submitted <textarea>:
<?php
$txt = $_POST['matrix'];
$mat = explode ("
", $txt);
for ($i = 0; $i < sizeof ($mat); ++$i)
$mat[$i] = explode (' ', $mat[$i]);
?>
Of course, the same code would work for values delimited by comma, or any
other delimiter you see fit.
A less intuitive way would be to present the user with a literal matrix of
<input> fields.

Read space separated string from file into a single variable 
char status[10];
char text[1024];
char number[1024];
char i[1024];
while(fscanf(file, "%s %s %s %s", status, text, number, i) != EOF) {
printf("%s %s %s %s
", status, text, number, i);
}
If you know the "number" field is always "number" and you know it's
followed by an int,
you can say:
char status[10];
char text[1024];
int i;
while(fscanf(file, "%s %s number %d", status, text, i) != EOF) {
printf("%s %s number %s
", status, text, i);
}
or
char line[1000];
while(fgets(line, 1000, file)) {
char *p;
for(p = strtok(line, "
"); p; p = strtok(p, "
")) {
printf("%s ", p);
}
printf("
");
}

jquery highlight on search of multiple words separated with space 
Plugin that you are using is very simple and strictly doesn't take an array
of strings to match nor it does the word separation itself. But generally
that is natural way of matching. But you can probably handle it in your
code by separating out words and calling highlight yourself.
$(function() {
$('#field1').bind('keyup change', function(ev) {
// pull in the new value
var searchTerm = $(this).val();
// remove any old highlighted terms
$('body').removeHighlight();
// disable highlighting if empty
if ( searchTerm ) {
var terms = searchTerm.split(/W+/);
$.each(terms, function(_, term){
$('body').highlight(term.trim());
});
}
});
});
Demo
here is an

MATLAB Insert matrix into 3D matrix 
For horizontal or vertial concatenation of matrices/vectors A and B, you
can use
% vertical
[A; B];
% horizontal
[A, B]; % comma is optional:
[A B];
There is no such notation for the third dimension. You'll have to use the
generalized concatenation in arbitrary dimension cat():
% Example matrices
A = rand(1437, 159, 1251);
B = rand(1437, 159);
% Insertion point
N = 384;
% How to do it
A = cat(3, A(:,:,1:N), B, A(:,:,N+1:end));

Using findpeaks and minpeakdistance in MATLAB to find peaks separated by distance rather than index 
findpeaks doesn't know anything about the xcoordinates or what you have
plotted. You need to specify MinPeakDistance in terms of indices. Here's
an example:
xData = 100:1:1;
yData = rand(1,100);
yData(10) = 100; % peak
yData(11) = 99; % not a peak
yData(50) = 100; % peak
yData(51) = 99; % not a peak
[pks,locs] = findpeaks(yData,...
'SortStr','descend',...
'MinPeakDistance',floor(length(yData)/4),...
'MinPeakHeight',floor(max(yData)/2)...
);
xLocs = xData(locs);
pks =
100 100
locs =
10 50

Make a matrix with input inside a DIV by mixing input values 
Should help:
var arr = [];
$('#a input').each(function () {
var that = $(this);
$('#b input').each(function () {
arr.push(that.val());
arr.push($(this).val());
});
});
Then go through the array and dynamically generate the HTML. You can treat
this like a matrix by stepping every 2 values.

How to change automatically the type of the excel file from Tab space separated Text to xls file? 
mv file.{xls,csv}
It's a csv file, stop treating it as an excel file and things will work a
lot better. :) There are nice csv manipulation tools available in most
languages. Do you really need the excel library?

How do i count 1 or more items in comma separated input in Shell 
Try count=$(echo ${2}  awk F, '{print NF}') instead  you have your
braces and quotes insideout.
Although, it seems your bigger problem is that awk appears to not be
executable... You might try which awk and ls l $(which awk) to see what's
up with that...

Using big matrix in Matlab 
You will find an answer here on reading/writing part of a .mat matrix.
%read
matObj = matfile('myBigData.mat');
loadedData = matObj.X(1:4,1:4);
%write
matObj.X(81:100,81:100) = magic(20);
EDIT
Here is some code showing the append function
A = ones(10,10);
save('A.mat', 'A','v7.3');
clear A
matObj = matfile('A.mat','Writable',true);
matObj.A(8:10,8:10) = ones(3,3) * 3; %modify
matObj.A(11,:) = ones(1,10)*4; %append
disp(matObj.A)
The full matlab help for .mat (including limitations) is here.

In PHP, how to save words separated by space and lines and put words in array 
use simple explode() function
$str="new sample string";
$str=preg_replace("/s+/", " ", $str);
$arr=explode(" ",$str);
print_r($arr);
output :
Array ( [0] => new [1] => sample [2] => string )

Matlab matrix with different Row Sizes 
I think matrices in MATLAB have to be of a rectangular shape (m x n). You
could sub in nonvalues for NaN as a placeholder. The way that I usually do
this is define the dimensions of the matrix in nested for loops and discard
elements by placing a NaN.
for i = 1:rows
for j = 1:5000
if timestamp != 0
yourmatrix(i, j) = timestamp;
else
yourmatrix(i, j) = NaN;
end
end
end
I don't completely understand all of your variables, so I can't put it
directly in your function, but you can probably put it in there somewhere.

Matrix concatenation in matlab 
if X is a 3x3 matrix to delete the second column do:
X(:,2) = []
Then, to delete the remaining second row do:
X(2,:) = []
this should do the trick. hope this helps, Scott

Matlab, Matrix operation 
Calling your index matrix I, try something like this:
mul = A(I(:,1),I(:,2)) * A(I(:,2),I(:,3)) and see if matlab can optimize it
for you.
I'm rather rusty in matlab notation, so please excuse if the statement just
plain out doesn't work.
EDIT: I think I don't fully understand what it is you're trying to
accomplish.

Sea Ice data  MATLAB 3D matrix 
Yes this can be done without too much difficulty. I have done analogous
work in analyzing atmospheric data across time.
The fundamental problem is that you have data organized by hour, with grids
varying dynamically over time, and you need to analyze data over time. I
would recommend one of two approaches.
Approach 1: Grid Resampling
This involves resampling the grid data over a uniform, standardized grid.
Define the grid using the Matlab ndgrid() function, then resample each
point using interp2(), and concatonate into a uniform 3D matrix. You can
then directly interpolate within this resampled data using interp3(). This
approach involves minimal programming, with the tradeoff of losing some of
the original data in the resampling process.
Approach 2: Dynamic Interpolation
Define a

Matlab , matrix operations 
This is one solution:
% sub2ind does not work, use this hack instead
z = zeros(size(A));
z(i2,i1) = 1
ind = find(z) % get linear indices
%only keep the ones for which A is nonzero
ind = ind(A(ind) ~= 0)
Result:
z =
0 0 0 0
1 0 1 0
0 0 0 0
1 0 1 0
ind =
2
4
10
12
ind =
2
4
12

Command Line Python Comma Separated User Input int Values 
"2,3" is a string, passing this to a function won't make it act like two
different parameters separated by ,(as you expected).
>>> def func(arg):
... print arg
...
>>> func('a, b')
a, b # arg is a variable that stores the passed string
You should convert that string into two numbers first by splitting it at
comma first and then applying int() to each if it's item.
>>> import math
>>> math.pow(*map(int, '2,3'.split(',')))
8.0
First split the string at ',' using str.split:
>>> '2,3'.split(',')
['2', '3'] #str.split returns a list
Now as we need integers so apply int() to each value:
>>> map(int, '2,3'.split(',')) #apply int() to each item of the
list ['2', '3']
[2, 3]
Now as pow expects tw

what is the algorithm for an RBF kernel matrix in Matlab? 
This should be what you are looking for. It is taken from here
% With Fast Computation of the RBF kernel matrix
% To speed up the computation, we exploit a decomposition of the Euclidean
distance (norm)
%
% Inputs:
% ker: 'lin','poly','rbf','sam'
% X: data matrix with training samples in rows and features in
columns
% X2: data matrix with test samples in rows and features in
columns
% sigma: width of the RBF kernel
% b: bias in the linear and polinomial kernel
% d: degree in the polynomial kernel
%
% Output:
% K: kernel matrix
%
% Gustavo CampsValls
% 2006(c)
% Jordi (jordi@uv.es), 2007
% 200711: if/then > switch, and fixed RBF kernel
function K = kernelmatrix(ker,X,X2,sigma)
switch ker
case 'lin'
if exist(

Multiplying matrix polynomials in MATLAB 
It's probably not the best solution, but you could reimplement conv for
matrices, e.g.:
function C = convMat(A,B)
nA = size(A,3);
nB = size(B,3);
n = nA + nB  1;
C = zeros([size(A,1),size(B,2),n]);
for k = 1:n
for j = max(1,k+1nB):min(k,nA)
C(:,:,k) = C(:,:,k) + A(:,:,j)*B(:,:,kj+1);
end
end
For your interest: Another (worse?) implementation:
function C = convMat2(A,B)
n = size(A,3) + size(B,3)  1;
C = zeros([size(A,1),size(B,2),n]);
for mA = 1:size(A,1)
for mB = 1:size(B,2)
for l = 1:size(A,2) % = size(B,1)
vA = A(mA,l,:);
vA = vA(:);
vB = B(l,mB,:);
vB = vB(:);
C(mA,mB,:) = C(mA,mB,:) + reshape(conv(vA,vB),[1,1,n]);

Summing regions of a matrix that do not over lap in matlab 
Since 7600 is evenly divisible by 20, you can reshape and sum:
a = rand(7600,1);
sum(reshape(a,20,7600/20))
EDIT Addressing comment for non evenly divisible lengths
b = 20;
sz = size(a);
% Last elements to exclude
excl = mod(sz(1),b);
% Sum reshape and sum excluded separately
[sum(reshape(a(1:endexcl), b, fix(sz(1)/b))), sum(a(endexcl+1:end))]

MatLab to convert a matrix with respect to 1st col 
I think options 1 is better, i.e. first make r, and then remove 99999.
Having r, u can remove 99999 as follows:
r2 = {}; % new cell array without 99999
for i = 1:numel(r)
rCell = r{i};
whereIs9999 = rCell == 99999;
rCell(whereIs9999) = []; % remove 99999
r2{i} = rCell;
end
Or more fancy way:
r2= cellfun(@(c) {c(c~=99999)}, r);

Matlab: accessing a matrix like a database 
The exact answer to your question is to use ismember:
octave> years = [2010 2011];
octave> ismember (M(:,1), years)
ans =
1
1
1
0
octave> M(ismember (M(:,1), years), 2)
ans =
5
7
8
However, depending what you gonna be doing with the data, it may be better
to rearrange it in some other way. For example, maybe a cell array, one
cell for each year holding an array with the values.
octave> M([2010 2011 2012]) = {[5 7] [8] [20]};
octave> M{2010}
ans =
5 7
Or if you gonna have more numbers for each entry, maybe a struct array with
each struct having multiple fields, one of them the year. I have written
before a recipe to deal with such data before.
But really, if your data gets complicated and you think need a database,
then this is probabl

matlab simple matrix manipulation 
If dimension are correct you can always use * operator
>> C = B*A
C =
1 2 3 4
2 4 6 8
3 6 9 12
4 8 12 16

Getting one section of a larger matrix matlab 
As schorsch said in comments, simply do:
A=M(160:430,108:305)
to get values
then modify your sample ( B=transform(A) )
and put B in the same way you got A out
M(160:430,108:305)=B
Remember that : basically means everything in between
I agree with Mark though, the documentation for MATLAB is outstanding and
one of MATLAB's best features compared to open source, utilize it please.

Algorithm for Matrix Inverse in MATLAB 
Sigh. People think that just because they learned in school that the
solution to A*X=B is to form X=inv(A)*B, that this is the thing to do. Yes,
your textbook said to do that. Amazingly, there are hordes of people out
there trying to teach you things like that. Sadly, they are wrong, and they
teach others to teach the wrong things, even putting it into books. This
foolishness propagates, never seeming to end. And even if the textbook
author knows themselves that AB is better in theory than inv(A)*B, it is
still easier to write it in the inverse matrix form.
Alert: You don't want to form the inverse matrix, and god forbid, you don't
want to use Gaussian elimination. (Let the pros do coding like that in a
compiled tool for you.) Instead, use backslash in MATLAB, which IS
efficient & wel


