Respondida
How do I know the frequency of each unique pair?
Here's a one-liner that works if the input is of a N-by-2 matrix with positive integers: A=uint8([1 2; 3 4;1 2;5 6;1 2;5 ...

más de 12 años hace | 0

Respondida
Average returns for diffferent companies
Assuming DATA is a cell array holding your data, something along these lines could work: [COMPANY,~,idx] = unique(DATA(:,...

más de 12 años hace | 0

Respondida
converting decimal matrix to binary matrix
Do you want the output in strings, as cells, or as numbers? M = [ 1 25 34 9 ] Mstr = dec2bin(M,8) % char array M...

más de 12 años hace | 0

Respondida
How do I determine if a value is unique within an iteration?
Doe the array nut changes during iterations? If not, you can find the unique indices into nut using UNIQUE [~,idx] = unique...

más de 12 años hace | 0

Respondida
how to delete all the elements from the matrix?
Several options, depending on the desired result (same class, for instance): A = [] A(:) = [] A = zeros(0,0,class(A))...

más de 12 años hace | 0

Respondida
fill a range with specified color
fill([A A],[b c],'r') help fill

más de 12 años hace | 0

Respondida
Changing duplicates in an array to zero?
x = [1 1 6 6 3 3 2 3 4 6 6 3 3 2 2 2 3 3 3] y = zeros(size(x)) [~,i] = unique(x,'first') y(i) = x(i)

más de 12 años hace | 1

Respondida
Interpolation command by MATLAB
The statement "shading interp" only causes the plot to be interpolated. To obtain the values you can use INTERP, INTERP1, INTERP...

más de 12 años hace | 0

Respondida
Random Vectors with Fixed Sum (algorithm of Roger Stafford)
I would cite the function as a website. Something like this suffices, I think: R. Stafford (2006). RandfixedSum, Matlab File ...

más de 12 años hace | 0

| aceptada

Respondida
find indices of string matches from a cell array by thier endings
You can use REGEXP to find a specific string property. Moreover you can combine various properties using the separator | ...

más de 12 años hace | 3

Respondida
I' am facing a error"Out of memory. Type HELP MEMORY for your options."
Use less memory … This means your matrices are too large. Do you really need to keep all data in your working memory? Can you...

más de 12 años hace | 0

Respondida
create subarray from an given array
This problem is somewhat ill-defined. If there are multiple group sizes allowed, should all group sizes be present an equal amou...

más de 12 años hace | 0

Respondida
How to find frequency of occurence of a specific element in a matrix per column??
tf = A(:,1) >= 0 & A(:,1) <= 2.5 % true, when within range tmp = A(tf,3:7) N55percolumn = sum(tmp==55,1)

más de 12 años hace | 0

| aceptada

Respondida
sir,i want to convert string into a hexadecimal value...is there any direct command?
Do you want to convert the string to a value? STR = input('Enter a hexadecimal number:','s') % the user types, for insta...

más de 12 años hace | 0

Respondida
run length encoding n decoding
Did you search the file exchange? I recommend this one by Urs: <http://www.mathworks.nl/matlabcentral/fileexchange/6436-rude...

más de 12 años hace | 0

Respondida
Calculating the probability of one bin preceding the other
Counting can be done using ismember tf11 = ismember(A,[1 1],'rows') ; % true for rows that are [1 1] N11 = sum(tf11) % c...

más de 12 años hace | 1

| aceptada

Respondida
How to have a user input prompt more user inputs?
N = str2double(inputdlg('How many inputs','N')) if ~isempty(N) && ~isnan(N) && N > 0 && N < 10 % sanity check! prompt...

más de 12 años hace | 0

Respondida
Resizing cells in a cell array
Let C be your cell array D = C(~cellfun(@(x) size(x,1) < 50 && size(x,2) < 40,C))

más de 12 años hace | 0

| aceptada

Respondida
how to draw random numbers from the vector
If V is your vector of numbers, and N the number of values you want from it, there are various options: V = 1:2:20, N = 5 %...

más de 12 años hace | 2

| aceptada

Respondida
Given a matrix A, and a matrix of column indices B, how to create a new matrix C from A and B
A = [ 5 8 3 4 8 1 9 6 8 ] B = [3 1 2 2 3 1 1 3 2] % B is an array of column indices % create the ...

más de 12 años hace | 0

| aceptada

Respondida
how to skip incomplete and missing lines when reading from Text file?
Empty lines are skipped. The real trouble is reading the incomplete lines. I suggest to read each line in as a string, and then...

más de 12 años hace | 0

Respondida
How can I delete rows in a matrix where two numbers exist side-by-side?
A = [2,7,3;1, 2, 1; 1, 2, 1; 2, 2, 3; 1, 2, 1; 2, 3, 4] i = 1:size(A,2)-1 tf = A(:,i)==2 & A(:,i+1)==3 % tr...

más de 12 años hace | 0

Respondida
How can I convert A matrix to B matrix below?
B = eye(size(A)).*A B = cumsum(B,1) + cumsum(B,2) - B

más de 12 años hace | 1

| aceptada

Respondida
matrix generation 1 to n*n or interval
reshape(1:n^2,n,n).'

más de 12 años hace | 1

| aceptada

Respondida
how to find correlation coefficient?
a = a(:) % transform into vectors b = b(:) plot(a, b, 'b.') xlabel('Value of a') ; ylabel('Value of b') ; lslin...

más de 12 años hace | 0

Respondida
Grid line for x=0 and y=0
Take a look at GRIDXY, available on the File Exchange: <http://www.mathworks.com/matlabcentral/fileexchange/9973-gridxy-v2-2-...

más de 12 años hace | 0

Respondida
How can I create an array of fixed length?
Maybe you want to pre-allocate z and c like this: z = zeros(size(z0)) ; c = zeros(size(z0)) ;

más de 12 años hace | 0

| aceptada

Respondida
Finding Sequences of 1's values
Another idea, not tested for speed: A = [0 0 0 0 0 0 1 1 1 0 0 0 0 0 1 1 0 0 0 0 1 1 1 1 1 0 0] B = cumsum(a) tf ...

más de 12 años hace | 0

Respondida
problem with the setdiff function
A = 2:.1:15 B = [9.4000 10.4000] D = 2 ; % number of digits that should match (e.g. 1.231 = 1.229) C = setdif...

más de 12 años hace | 0

Respondida
'rotating' matrix data around one point
You can use CIRCSHIFT to move the a point to the centre of the matrix, and then apply ROT90 to rotate it, and apply CIRCSHIFT ag...

más de 12 años hace | 0

Cargar más