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...

7 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')...

7 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...

7 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 = ??...

7 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...

7 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...

7 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...

7 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...

7 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...

7 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...

7 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...

7 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...

7 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 ...

7 years ago | 1

| accepted

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

7 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...

7 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-...

7 years ago | 0

| accepted

Answered
Error using copyfile (Cannot copy or move a file or directory onto itself)
Your copyfile sytnax is incorrect. Try this: copyfile(FilenameR,Filename)

7 years ago | 1

| accepted

Answered
Reading files and writing with new extension
Use fileparts, something like this: [~,fnm] = fileparts(jpgFiles{i}); fullfile(myFolder, sprintf('%s.txt',fnm))

7 years ago | 0

| accepted

Answered
Converting .mat file with integer values to .dat causing wrong placement of the floating point
save writes text files using exponential notation. If you don't want exponential notation, don't use save In any case, using c...

7 years ago | 1

Answered
match vector with first column of matrix
Simpler with just one ismember call and some basic indexing: >> [idx,idy] = ismember(v(:),Mat(:,1)); >> res = [v(:),v(:)]; >>...

7 years ago | 2

| accepted

Answered
Matching elements in a matrix with elements in another matrix
>> [idx,idy] = ismember(A,B(:,1)); >> C = nan(size(A)); >> C(idx) = B(idy(idx),2) C = 333 112 789 112 333 762...

7 years ago | 0

| accepted

Answered
Loops slowing down dramatically with increased iterations
"...any suggestions to increase efficiency" Do not use cd to read data files, always use absolute/relative filenames. Yes reall...

7 years ago | 0

| accepted

Answered
Local functions vs. private functions
In my experience: files in a private folder are easier to maintain with version control. as each file encapsulates one function...

7 years ago | 1

| accepted

Answered
Naming figures based on the current value in a for loop
It is not possible to combine these two syntaxes into one figure call: fgh = figure(k); set(fgh, 'Name','Question 3 Part 4', '...

7 years ago | 0

Answered
Using fprintf: string in array is NaN
No need to convert data to string: >> data.x = [0;1;0;1]; >> data.y = [1;1;1;1]; >> data.z = [0;0;0;0]; >> data.name = {'Lau...

7 years ago | 0

| accepted

Answered
Unexpected behavior of mean function
"Can anyone tell me why I got this answer?" You called the command syntax of mean: https://www.mathworks.com/help/matlab/matla...

7 years ago | 1

Answered
Change for loop stepsize
This syntax does not do what you think it does: phaseerror == 0.0000000001||0.000000001||0.00000001||0.0000001||0.000001||0.000...

7 years ago | 0

Answered
Undefined function 'interp' for input arguments of type 'double'
MATLAB does not have an interp function, probably you meant to use interp1

7 years ago | 0

Answered
Replace multiple matrix in a cell array based on condition
You were almost there, just one small change is required: To assign to an unknown number of LHS elements the RHS must be scalar...

7 years ago | 1

| accepted

Answered
Find the exact multiple of a number by zero padding values.
Method One: create the output matrix first, then use indexing to add the values: R = 173; B = zeros(R,ceil(numel(A)/R)); B(1:...

7 years ago | 0

| accepted

Load more