Answered
Adjusting the dimensions of input argument
A = A(:).';

7 years ago | 1

| accepted

Answered
How to convert string to number?
"...how do I convert it back to a number?" Convert to numeric: num = str2double(id1) "Now i want to check if the value is a n...

7 years ago | 0

Answered
How can I make a random RGB array of either White Cells or Green Cells (or any two colours)?
This generates MATLAB standard 0-1 values (multiply by 255 and use uint8 if required): >> R = 5; >> C = 7; >> X = rand(R,C)<0...

7 years ago | 0

| accepted

Answered
Access to array of structs (no for loops)
"Is there a way to access all end values of datarow with one command (no for loops or temporary variables)?" Nope. "Anyone som...

7 years ago | 0

| accepted

Answered
Matlab adds a minor number to integer - why?
"i noticed a very strange phenomanon:" Nope, not strange at all. "what is the "3" in the end..." Accumulated floating point e...

7 years ago | 1

Answered
The usage of [~,I]=min(abs(A+B)) on a specific example
I don't really see how min can help you. Basic logical indexing would be simpler, e.g.: >> nnz(u<umin | u>umax) ans = 4 Note...

7 years ago | 0

| accepted

Answered
Variable changes to previously calculated value each iteration.
This is very easy with a preallocated vector (giving exactly the values as you stated here): X = 100:440; N = numel(X); Z = n...

7 years ago | 1

| accepted

Answered
Concatenation of variables inside a struct
Method one: size and repelem: >> cnt = arrayfun(@(s)size(s.latlon,1),str); >> out = repelem(cat(1,str.val),cnt) out = 200...

7 years ago | 0

| accepted

Answered
How can I create a cell array whose elements reflect a length based on a given input vector?
In one line: >> V = [3,2,4]; >> S = 'b'; >> C = mat2cell(repmat(S,1,sum(V)),1,V); >> C{:} ans = bbb ans = bb ans = bbbb

7 years ago | 0

| accepted

Answered
Multi-conditional statements for array lookup (similar to multi-conditional vlookup from Excel)
You could use tables and innerjoin: >> tA = cell2table(A,'variableNames',{'class','thickness'}) tA = class thickness ...

7 years ago | 1

| accepted

Answered
Creating folders outside of the current folder
Of course, just define the parentFolder, or use a relative/absolute path: https://www.mathworks.com/help/matlab/ref/mkdir.html#...

7 years ago | 0

| accepted

Answered
Adding neighboring numbers in a cell to another cell
CA = {[5,-10,2],[6,6,-10],[0,9,-10,8,-10,3]}; CB = {[4,17,2],[6,6,10],[9,3,4,9,7,6]}; for k = 1:numel(CA) idx = 1+find(-1...

7 years ago | 0

| accepted

Answered
How to append structure fields with same name and different length
You did not explain how these (identically named) files are saved (i.e. what the folder structure is like), so I simply put your...

7 years ago | 0

| accepted

Answered
Using randperm without involving the first and last number
N = 9; [1,1+randperm(N-2),N]

7 years ago | 1

| accepted

Answered
Check if file exists (without having the full name)
You might like to download my FEX submission nextname: https://www.mathworks.com/matlabcentral/fileexchange/64108-next-availabl...

7 years ago | 0

Answered
How to avoid cell2mat while reshaping cell arrays
Simple way using concatenation: C = {rand(55430,2350),rand(55430,2200)}; % fake data D = num2cell(horzcat(C{:}),2); But I gue...

7 years ago | 0

| accepted

Answered
Removing NaNs from a struct
This works for any sized fields (including empty), and gives you the choice of matching ALL or ANY of the fields containing NaN....

7 years ago | 2

| accepted

Answered
round function on complex numbers
This has nothing to do with rounding. Either change the format, e.g.: >> format short g >> a = [1,1,1,1; 1 -j -1 -1; 1 -1 1 -1...

7 years ago | 1

Answered
MyFunction Call generates Error
The problem is that you think that you wrote a function, but you actually wrote a script: https://www.mathworks.com/help/matlab...

7 years ago | 0

Answered
How do I split a string of numbers in n+1th successive intervals and put them in a array or matrix.
>> S = '123456123456123456123'; >> [C,T] = regexp(S,'(\d)\d{0,6}','match','tokens'); >> D = strcat(C(:),vertcat(T{2:end},{''})...

7 years ago | 1

Answered
how would you write a function that operates on both character and numerical arrays
The simple answer to your question is do NOT define B before the loop, i.e.: function B = reverseAppend(vectorVal) % NO B! fo...

7 years ago | 1

| accepted

Answered
How can I mat2cell the array?
>> v = {1,8,1,1,6,1,2,5,3,2,7,11,7,9,10,9}; >> c = regexp(char([v{:}]),'(.).*?(??$1)','match'); >> c = cellfun(@double,c,'uni'...

7 years ago | 0

| accepted

Answered
Undefined operator .^ occurs help!!
"I just wrote everything on the given material" If that is the case then that material is wrong: {} creates a cell array (simi...

7 years ago | 1

| accepted

Answered
Extract data from text file
That is a very badly formatted file. For example, the field delimiters are space characters and space characters also occur with...

7 years ago | 2

| accepted

Answered
Removing specific elements from array
>> a = [1,1,3,5]; >> c = [1,5]; >> [X,Y] = ismember(c,a); >> a(Y(X)) = [] a = 1 3

7 years ago | 1

| accepted

Answered
creating a new column in a matrix using 'if condition"
IF will not help you in this situation. You need to use indexing, e.g.: Reg1(:,10) = a1-b1*Reg1(:,3) + Reg1(:,6); idx = Reg1(...

7 years ago | 0

| accepted

Answered
Converting serial date numbers to datetime array
>> t = datetime(.3718505035,'ConvertFrom','datenum','Format','HH:mm:ss.SSS') t = 08:55:27.883 "also I need to apply the fu...

7 years ago | 0

Answered
How can I create a random array like the example C?
A = [1,1,2,2,7,7,9,9]; B = [3,5,6,8,10,11]; Na = numel(A); Nb = numel(B); Xb = randperm(Nb) % to shuffle the order of B. Xa...

7 years ago | 1

| accepted

Answered
Is there no difference between logical and uint8 regarding disk space (or memory)?
"I understand that binary means 1-bit which consists of 1 and 0." Nope, binary data is stored with one byte per element: https...

7 years ago | 0

| accepted

Load more