Answered
Extracting string and number pairs from a mixed string
The two lines marked with %%% are used to convert substrings like '(Fe0.5Co0.5)58.5' into 'Fe29.25Co29.25', after which the desi...

6 years ago | 1

| accepted

Answered
How can I convert a number to time?
>> V = randi(58232,7,1) % fake data V = 7565 33124 27334 694 19632 9445 ...

6 years ago | 0

| accepted

Answered
how to Vectorize this for loop
Try doing something like this: [fid,msg] = fopen('CANDec(day_1_9).txt','rt'); assert(fid>=3,msg) % good practice to check the ...

6 years ago | 0

| accepted

Answered
scalar vs matrix vs vector vs array??
Just like in mathematics, the only difference is their size. MATLAB does not have special classes for scalars, vectors, matrice...

6 years ago | 3

| accepted

Answered
Reducing repeated elements in an array by a factor
>> V = [1,2,2,2,2,2,2,5,6]; >> N = 3; >> X = cumsum([1,diff(V)~=0]); >> F = @(v) {v(1:ceil(numel(v)/N))}; >> cell2mat(accuma...

6 years ago | 2

| accepted

Answered
Storing Function Handles in structure
>> fun = @(x,y,z) [x,y,z]; >> baz = @(n,v) v(n); % helper function >> a = @(n) @(x,y,z)baz(n,fun(x,y,z)); Testing: >> f = a(...

6 years ago | 1

| accepted

Answered
creating channels in an array
"What does this error mean?" You are trying to access array elements that do not exist! You defined h to have size 4x5(x1x1x1....

6 years ago | 0

| accepted

Answered
Problem using for loop
a = 1:10; n = numel(a); for kk = 1:n for ii = max(1,kk-2):min(n,kk+2) x = a(ii); end end

6 years ago | 0

| accepted

Answered
how to use interp1() function
The problem is that you are using the default x values, which for a vector input are defined as 1:numel(v) These default point...

6 years ago | 0

| accepted

Answered
Error using textscan Mismatch between file and format character vector. Trouble reading 'Numeric' field from file (row number 1, field number 3)
The second field is clearly not numeric, containing values like 020520t1xy10z12.tif 020520t1xy10z12.tif 020520t1xy10z12.tif ...

6 years ago | 1

Answered
Insert zero columns in matrices inside a cell array
Where C is your cell array: for k = 1:numel(C) C{k}(:,end+1:30) = 0; end

6 years ago | 0

| accepted

Answered
Delete values in one matrix that aren't contained in a second matrix
>> M1 = dlmread('coordiates_variable.dat'); >> M2 = dlmread('coordinates.txt'); >> idx = ismembertol(M1(:,1:3),M2, 0.0001, 'By...

6 years ago | 0

Answered
How to convert a 8760X30matrix to a 365X30 matrix?
>> inp = rand(8760,30); % fake data matrix >> out = mean(permute(reshape(inp,24,[],30),[2,3,1]),3); And checking: >> size(out...

6 years ago | 0

| accepted

Answered
for-loop over Structure Array
"Can anybody exlpain to me, why this happens" Because MATLAB is (as far the end-user is concerned) pass-by-value and not pass-b...

6 years ago | 0

| accepted

Answered
Dynamic on the fly expression/function
Vector Indices: You can do this quite easily by generating vectors of indices and taking advantage of the fact that addition and...

6 years ago | 1

| accepted

Answered
how to call a variable inside a function
No need for a loop: nAZ = histc(char(lower(stateNames)).','a':'z').'; E.g.: >> nAZ = histc(char(lower(stateNames)).','a':'z')...

6 years ago | 0

Answered
Text file i/o problem....I always get 0 with charnum ...whats the problem with the code??
Your code has likely has several bugs, e.g. you were checking for literal "character" as opposed to using the contents of the ch...

6 years ago | 0

| accepted

Answered
how to do a loop and call a function
As described in the question, you will have to do something like this: L = ???; D = ???; P = ???; r = ???; c = ???; a = ??...

6 years ago | 0

Answered
Undefined function 'de' for input arguments of type 'double'.
"... the vector "de" is well defined in mdlderivatives of my s-function." And that is part of the problem: mdlderivatives has a...

6 years ago | 0

| accepted

Answered
How can I save the differents values of a variable which is into a for loop?
Just use indexing, e.g.: Ckk = cell(1,nel); for iel = 1:nel ... your code Ckk{iel} = ... variable you want to stor...

6 years ago | 0

Answered
error during selecting dynamically image from folder
"I want to randomaly select 8 images from specific folder how i can do that" Something like this: P = 'path to the folder wher...

6 years ago | 0

| accepted

Answered
How to compare the saved names of two images stored in different folders ?
I don't think imageDatastore particularly helps in this case. Something like this: P1 = 'G:\MTech\InputImages'; P2 = 'G:\MTech...

6 years ago | 1

| accepted

Answered
I have a matrix A = [1 1 0 0 1 1]
>> A = [1,1,0,0,1,1]; >> B = toeplitz([0,A]) B = 0 1 1 0 0 1 1 1 0 1 1 0 0 1 1 1 0 1...

6 years ago | 0

Answered
How can I run many .mat files in loop .?
How to process multiple files is explained in the MATLAB documentation: https://www.mathworks.com/help/matlab/import_export/pro...

6 years ago | 0

Answered
What is the meaning of this word !
Apparently you are using this third-party toolbox: https://github.com/petercorke/robotics-toolbox-matlab As far as I understan...

6 years ago | 1

| accepted

Answered
how to replace all elements with zeros after "ONE" (number) in every column of matrix???
>> mat = randi([0,1],[6,8]) mat = 1 0 0 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 0...

6 years ago | 1

Answered
Writing function for fliping vectors
The main problem is that you are not returning the variable that you flip. You ignored the input argument (which already breaks ...

6 years ago | 1

| accepted

Answered
divide 3d matrix (840,64,1536) by 1d matrix (1536,1)
bsxfun(@rdivide,A,reshape(B,1,1,[]))

6 years ago | 1

| accepted

Answered
How to make a column of cells into array? Each cell in a row when made into an array would a row with different number of columns
Download Jos's padcat: https://www.mathworks.com/matlabcentral/fileexchange/22909-padcat and use it like this: M = padcat(Sce...

6 years ago | 0

| accepted

Answered
How to load field values in struct file
S = load('Outputs/Agg/Scenario1_indvoutputagg'); C = S.ndvoutputagg; https://www.mathworks.com/help/matlab/matlab_prog/access-...

6 years ago | 0

| accepted

Load more