Risposto
How to assign value in an array depending on the index stated in another array
Welcome to the world of indexing! Your problem: a = [2 5 9] b = [0 0 0 0 0 0 0 0 0 0]; b(a) = 1 Other interesti...

quasi 13 anni fa | 3

Risposto
this program taking a long time to run and i did't get the answer also due to this problem. how can i reduce this time
The slowness is caused by the fact to you expand the matrix s and sometimes the matrix data2 in each iteration. You should preal...

quasi 13 anni fa | 0

Risposto
How can I calculate the difference in time (seconds) with datetime?
You can also use the dedicated function ETIME (with DATEVEC) date1 = '2014/01/16 13:12:12' date2 = '2014/01/16 13:12:13'...

quasi 13 anni fa | 3

Risposto
How to perform cancatenation of binary numbers using matlab
If the values are stored as strings (character arrays): a = '1011' , b = '0011', c = '0101' out = [a b c] % simple chara...

quasi 13 anni fa | 0

Risposto
combine each entry of a cell array and a double array
So is A is a *cell array of chars*, and B is a standard array of doubles, and you want to combine it into a cell array of chars....

quasi 13 anni fa | 0

| accettato

Risposto
Frustrating for what should be simple… What have I done wrong?
Another option with strings is to use SWITCH-CASE-END in combination with a WHILE-loop and a BREAK statement. The big advantage ...

quasi 13 anni fa | 0

Risposto
minimizing a function with matrix output
You can define an error function that you minimise with fminsearch. The function obj and the arguments H12, H21, F1 and F2 shoul...

quasi 13 anni fa | 0

| accettato

Risposto
Solving permutation/combination example with MATLAB
hints (1) start with 1 box with M balls, drawing n balls from it. This will give you the set S(n). Take a look at <http://www...

quasi 13 anni fa | 0

| accettato

Risposto
How to generate matrix using MATLAB ?
An easy way: m = kron(eye(24),ones(1,4))

quasi 13 anni fa | 0

Risposto
combine each entry of a cell array and a double array
Your talking about doubles in B? What does A1B1 mean in that case? What is A1 % Assuming all doubles A = {10 ; 11 ; 12} ...

quasi 13 anni fa | 0

Risposto
Grouping a given matrix into sub matrices
Let M be your matrix with time in the first column [~, ix] = histc(M(:,1), 0:0.1:0.8) C = group2cell(M(:,2),ix) No...

quasi 13 anni fa | 0

Risposto
i need help for string code
The following might give some insight a1 = 1 ; a2 = 2 ; A = {a1 a2} ; % declaration disp(A) A{1} = 10 ; % change the ...

quasi 13 anni fa | 0

Risposto
How to average within bins? Indexing again...
Using ACCUMARRAY to average the values belonging to the same bin: dist = [2 4 6 9] ; duration = [3 4 10 11]; bin ...

quasi 13 anni fa | 1

Risposto
how can i add 1-40,41-80, 81-120 and so on till 14000 datapoints which is in a text file?
In cases when the total number of elements is not divisible by the size of the smaller groups, and reshape cannot be used, this ...

quasi 13 anni fa | 0

Risposto
print numbers in Enginering Notation
Separate the mantissa and the exponent Values = [pi ; 1.12301230123e17 ; 100000 ; 9999999999999] E = floor(log10(Value...

quasi 13 anni fa | 0

| accettato

Risposto
How to split a matrix in different sections in a loop?
A=[ 1 2 3 1 ; 4 5 6 1 ; 2 3 4 2 ; 5 6 7 2 ; 8 9 3 2 ; 5 1 2 4 ; ...

quasi 13 anni fa | 0

| accettato

Risposto
How to read a selected number from a string?
str = '# Source Interval: 22.99 u (ID: 2)' v = strread(str,'# Source Interval: %f%*[^\n]') % The format specifier means th...

quasi 13 anni fa | 1

| accettato

Risposto
how to delete adjacent entries from an array
Let N be the number of items that is to be removed before and after the locations of the value V in A. (so there are 2*N+1 items...

quasi 13 anni fa | 0

| accettato

Risposto
Is possible put a vector as a diagonal of matrix ?
A = [1 2] ; n = 3 ; B = kron(eye(n),A)

quasi 13 anni fa | 0

Risposto
one line form of the follwing code
You want a one-liner? Try these: catchFolders = {'iptCatch','imtCatch','iftCatch','','junk','iitCatch'} % data catchF...

quasi 13 anni fa | 0

| accettato

Risposto
How to divide the data of a matrix?
TIMES = DATA(:,1) ; VELS = DATA(:,2) ; TakeTheCountOfTheVelocityFunction = @(V) numel(V) ; % or whatever you mean b...

quasi 13 anni fa | 0

Risposto
Save FOR loop data into a vector
Note that you can loop over elements X = [1 3 5 2 3 4 1] Y = zeros(size(X)) ; % pre-allocation makes loops faster k =...

quasi 13 anni fa | 0

Risposto
Converting base 10 to base 2, dec2base help
X = dec2base(4,2) whos X % X is a character array! fprintf('%g', X) % prints out ascii codes of the string!, Simil...

quasi 13 anni fa | 0

| accettato

Risposto
count occurrences of string in a single cell array (How many times a string appear)
A faster method and more direct method of counting using the additional output of UNIQUE: XX = {'computer', 'car', 'compute...

quasi 13 anni fa | 6

Risposto
create a matrix with elements as mean values of another matrix
Just to show the many roads to Rome in MatLab's world: A = ceil(10*rand(10,4)) B = cell2mat(arrayfun(@(x) sum(A(1:x,:),1...

quasi 13 anni fa | 0

Risposto
How to round the decimals?
A = [pi exp(1) 1/7] Ndecimals = 2 f = 10.^Ndecimals A = round(f*A)/f

quasi 13 anni fa | 4

| accettato

Risposto
finding similar rows in matrices
INTERSECT or ISMEMBER come into mind: tf = ismember(C, A(ismember(A,B,'rows')), 'rows') result = C(tf,:)

quasi 13 anni fa | 0

Risposto
Please help me to solve this problem!
Did you check the contents of each variable?

quasi 13 anni fa | 0

Risposto
Create an array from another and find the indices.
MySet = {'S' 'V' 'SV' 'S' 'V' 'V' 'S' 'SV' 'V'} MyStr = 'V' tf = strcmp(MySet, MyStr) index = find(tf) KeepSet...

quasi 13 anni fa | 0

| accettato

Risposto
Random integer numbers using random function
Two strings of 9 random digits between 1 and 9 each (no 0?), stored in a row cell(?) array? S = cellstr(char('0' + ceil(9*r...

quasi 13 anni fa | 1

Carica altro