Answered
overwrite cell array in a loop
|clear| the cell array before you implicitly create it with that allocation: clear P P{4}=[]; ... clear P P{2}=...

8 years ago | 1

| accepted

Answered
convert a 1*16 matrix to a 2*8 matrix
>> V = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]; >> reshape(V,[],2).' ans = 1 2 3 4 5 6 7 8 ...

8 years ago | 1

| accepted

Answered
how to decrease for loop variable counter when deleting rows in a matrix
Just specify the |for| loop values to count downwards: for i = size(A,1):-1:1 ... end

8 years ago | 2

| accepted

Answered
Replace elements in matrix based on indices stored in another matrix
Just use indexing, which is simple and very efficient: >> C{1} = [3:10, 17:21, 28]; >> C{2} = [11:13, 22:24, 29:30]; ...

8 years ago | 0

Answered
clear function does not work
<https://www.mathworks.com/matlabcentral/answers/316681-matlab-doesn-t-release-memory-when-variables-are-cleared>

8 years ago | 0

Answered
Assigning a function that does not exist to a new function?
Your misunderstand several fundamental aspects of MATLAB functions and variable assignment. _"In this program function CONTRO...

8 years ago | 0

Answered
Help with Reshaping Multidimensional Arrays
reshape(permute(A,[1,3,2]),x*y,3)

8 years ago | 1

| accepted

Answered
How to create loop for column
>> vec = 1:21; >> 1+mod(vec(:)-1,7) ans = 1 2 3 4 5 6 7 1 2 ...

8 years ago | 0

Answered
How can I generalise this?
This is easy when you sensibly store data in *one* array: >> x = [0,1]; >> y = [0,1]; >> c = {x,x,y}; >> d = cell(...

8 years ago | 1

Answered
Writing cell array with inconsistent size cells to txt
[fid,msg] = fopen('celldata.csv','wt'); assert(fid>=3,msg) for k = 1:numel(allAreasV) fprintf(fid,'%d,',allArea...

8 years ago | 1

| accepted

Answered
When i do decimal to binary conversion for a "test.doc" file which contains data as "WELCOME TO PROGRAMMING" i get some binary values.Same file whn i convert it to pdf i.e,"test.pdf" & do decimal to binary conversion i get different binary value why?
Nothing in your code has anything to do with the contents of those files. None of your code reads any file data, or accesses the...

8 years ago | 0

| accepted

Answered
How to store each vector subtraction data to a mat.file
First |clear| the (very badly named) variable |diff| from the workspace, then try this: S = load('coordinate.mat'); a = ...

8 years ago | 0

| accepted

Answered
How to apply function on every pair of rows of a matrix?
Perhaps something like this: d = @(x,y)+(x==1&y==-1); sum(bsxfun(d,permute(M,[1,3,2]),permute(M,[3,2,1])),3) And test...

8 years ago | 1

Answered
How to find which group of array belong to a certain position in a string?
>> seq = 'MQRSPLEKASVFSKLFFSWTRPILRKGYRQ'; >> mat = reshape(aaSeq,5,[]).' mat = MQRSP LEKAS VFSKL FFSWT R...

8 years ago | 1

| accepted

Answered
Copy data for one table to another
[~,idx] = ismember(B.Fecha,A.Fecha); B.coeff = A.values1(idx) Or B = A(idx,:) <https://www.mathworks.com/help/...

8 years ago | 0

| accepted

Answered
How to store cell array inside a cell array?
[c{1,1:32}] = deal(cell(1,3)); or simpler: [c{:}] = deal(cell(1,3)); or even just: c = repmat({cell(1,3)},1,32...

8 years ago | 2

| accepted

Answered
I dont get the result as i expect for the determinant of a simple 3x3 matrix
<https://www.mathworks.com/matlabcentral/answers/381548-using-matlab-s-det-why-does-this-3x3-matrix-s-determinant-not-zero> H...

8 years ago | 0

Answered
Split array into separate arrays, where difference between values exceeds a specific number
X = cumsum([true,diff(A)~=1]); C = accumarray(X(:),A(:),[],@(m){m});

8 years ago | 2

| accepted

Answered
Creating arrays for plotting purposes
Z = sqrt(((R1.*R2).^2+(R1./(w*C)).^2)./((R1+R2).^2+1/(w*C)^2)); ^^ you need to use RDI...

8 years ago | 0

| accepted

Answered
maximum value array of multiple arrays
Put the data into one array and use the third |dim| argument: arr = cat(3,A,B,C,...) min(arr,[],3) max(arr,[],3) I...

8 years ago | 0

| accepted

Answered
How to take first element from the cell?
Something like this (untested, but should get you started): N = numel(d); R = cell(1,N); X = cell(1,N); for k = 1:...

8 years ago | 0

Answered
Is time linear inside an ode45 function?
_"Is time within a function being solved using ode45 linear"_ Time is linear in the sense that the difference between 1 and 2...

8 years ago | 0

| accepted

Answered
How can I count all pixel values that are not black(0)?
Where |I| is your image: nnz(I) Note that this is robust to using different values for encoding the non-zero value in th...

8 years ago | 0

Answered
I have a series of variables form a1 to a100 and each one has a single numeric value. I want to repeat copies of that value to 1-by-4 matrix for all of them.
Your script |Trial1.m| (attached) is pointlessly complex, and using |eval| to access variables names just complicates things eve...

8 years ago | 1

| accepted

Answered
How to plot a 1 x 1 struct with 175 fields in Matlab
Unfortunately putting numbers into fieldnames like that makes it all rather tricky, because putting (meta)-data into the fieldna...

8 years ago | 0

| accepted

Answered
How to extract Jan and feb dates from an array of date strings?
>> C = {'1/1/2018'; '2/1/2018'; '12/31/2018'}; >> X = cellfun('isempty',regexp(C,'^[12]/','once')); >> D = C(~X)

8 years ago | 0

| accepted

Answered
In the following code if the condition is met i want to remove those two respective elements from the array 'New'. But i get an error saying 'Index exceeds matrix dimensions'.
This is a common beginner mistake. If you remove the first element of a four element vector, then it resizes to have three eleme...

8 years ago | 0

Answered
import sequential files using for loop and sprintf
Using a for loop and |sprintf|, exactly as the question title requests: V = 1:50; % the file numbers that you want to impor...

8 years ago | 0

| accepted

Answered
Two y axis without using plotyy
Create two axes. For the top axes set the |YAxisLocation| to |right|, the |Color| to |none|, and |NextPlot| to |replacechildren|...

8 years ago | 0

| accepted

Answered
Acces directories of specific name
You can get the path of the working folder by using |fileparts|: [workpath,subfolder] = fileparts(folder) Once you have ...

8 years ago | 0

| accepted

Load more