Réponse apportée
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...

plus de 12 ans il y a | 3

Réponse apportée
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...

plus de 12 ans il y a | 0

Réponse apportée
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'...

plus de 12 ans il y a | 3

Réponse apportée
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...

plus de 12 ans il y a | 0

Réponse apportée
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....

plus de 12 ans il y a | 0

| A accepté

Réponse apportée
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 ...

plus de 12 ans il y a | 0

Réponse apportée
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...

plus de 12 ans il y a | 0

| A accepté

Réponse apportée
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...

plus de 12 ans il y a | 0

| A accepté

Réponse apportée
How to generate matrix using MATLAB ?
An easy way: m = kron(eye(24),ones(1,4))

plus de 12 ans il y a | 0

Réponse apportée
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} ...

plus de 12 ans il y a | 0

Réponse apportée
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...

plus de 12 ans il y a | 0

Réponse apportée
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 ...

plus de 12 ans il y a | 0

Réponse apportée
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 ...

plus de 12 ans il y a | 1

Réponse apportée
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 ...

plus de 12 ans il y a | 0

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

plus de 12 ans il y a | 0

| A accepté

Réponse apportée
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 ; ...

plus de 12 ans il y a | 0

| A accepté

Réponse apportée
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...

plus de 12 ans il y a | 1

| A accepté

Réponse apportée
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...

plus de 12 ans il y a | 0

| A accepté

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

plus de 12 ans il y a | 0

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

plus de 12 ans il y a | 0

| A accepté

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

plus de 12 ans il y a | 0

Réponse apportée
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 =...

plus de 12 ans il y a | 0

Réponse apportée
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...

plus de 12 ans il y a | 0

| A accepté

Réponse apportée
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...

plus de 12 ans il y a | 6

Réponse apportée
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...

plus de 12 ans il y a | 0

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

plus de 12 ans il y a | 4

| A accepté

Réponse apportée
finding similar rows in matrices
INTERSECT or ISMEMBER come into mind: tf = ismember(C, A(ismember(A,B,'rows')), 'rows') result = C(tf,:)

plus de 12 ans il y a | 0

Réponse apportée
Please help me to solve this problem!
Did you check the contents of each variable?

plus de 12 ans il y a | 0

Réponse apportée
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...

plus de 12 ans il y a | 0

| A accepté

Réponse apportée
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...

plus de 12 ans il y a | 1

Charger plus