Answered
Reading files from a directory
How to read multiple files is explained extensively in the documentation, on this forum, and in the wiki: <https://www.mathwo...

9 years ago | 1

| accepted

Answered
Is there a color database existent?
Download my FEX submission |colornames|: <https://www.mathworks.com/matlabcentral/fileexchange/48155-convert-between-rgb-and-...

9 years ago | 1

| accepted

Answered
Write a function called year2016 that returns a row-vector of struct-s whose elements correspond to the days of a month in 2016 as specified by the input argument. If the input is not an integer between 1 and 12, the function returns the empty array.
This code does the job (copied from my answer to <https://www.mathworks.com/matlabcentral/answers/315751-how-to-request-addition...

9 years ago | 0

| accepted

Answered
How can I fill a structure array with a scalar array?
If you have a <https://www.mathworks.com/help/matlab/matlab_prog/access-multiple-elements-of-a-nonscalar-struct-array.html non-s...

9 years ago | 8

| accepted

Answered
Variable size: does it reflect real size after computation finishes?
A structure does not really _contain_ any arrays, but is a list of _links_ to other arrays in memory (some might call this an _"...

9 years ago | 0

| accepted

Answered
How can i plot a marker which is only half solid?
Download this FEX submission: <https://www.mathworks.com/matlabcentral/fileexchange/39487-custom-marker-plot> Or try the s...

9 years ago | 0

| accepted

Answered
How to add both a comma AND a carriage return to a file during export
You could use <https://www.mathworks.com/help/matlab/ref/fprintf.html |fprintf|>: fid = fopen(fnm,'wt'); fprintf(fid,'%d...

9 years ago | 0

| accepted

Answered
how to Sum Array with "for" loop ?
Use <https://www.mathworks.com/help/matlab/ref/cumsum.html |cumsum|>, e.g.: >> B = 1:5; >> cumsum(B) ans = ...

9 years ago | 1

| accepted

Answered
How to extract the first part of an array of strings by pattern?
If you want the part of the string before the first underscore |'_'|, then you can use <https://www.mathworks.com/help/matlab/re...

9 years ago | 0

| accepted

Answered
Allowing for code to work different with file names
How to read multiple files is explained extensively in the documentation, on this forum, and in the wiki: <https://www.mathwo...

9 years ago | 1

Answered
Embedding an array into another: vectorization method
One very simple and efficient way is to use <https://www.mathworks.com/help/matlab/ref/interp1.html |interp1|> with its |previou...

9 years ago | 2

Answered
Can anybody help me in figuring out this coding? It gives me the following error : (Undefined function 'rfk45' for input arguments of type 'function_handle'. Error in Example_11_03 (line 37) [t,f] = rfk45(@rates,tspan,f0);. )
|rfk45| in not a standard MATLAB function. You will either need write it yourself or get it somewhere else... there are several ...

9 years ago | 0

| accepted

Answered
How to split a vector into unequal sections?
>> V = [1;1;2;2;2;2;3;4;4;5]; >> D = diff(find([1;diff(V)~=0;1])); >> C = mat2cell(V,D,1); >> C{:} ans = 1 ...

9 years ago | 2

| accepted

Answered
distinguishing exponential (e) from other characters with regexp
'[+-]?\d+\.?\d*([eE][+-]?\d+)?' PS: If each string contains just one number then you should consider using the |'once'| opt...

9 years ago | 2

| accepted

Answered
hii, can anyone please tell me the problem in the code ?why find doesn't give me the index of the number in theta array thanks
The problem is that you are testing for equality of floating point values: <https://www.mathworks.com/matlabcentral/answers/5...

9 years ago | 0

| accepted

Answered
using regexp with negative and positive floating numbers
regexp(data,'[+-]?\d+\.?\d*', 'match'); Notes: # important: *|.|* does NOT match the period character, but in fact it ma...

9 years ago | 5

| accepted

Answered
Add a new array to a strucure
Taking a guess that you have a <https://www.mathworks.com/help/matlab/matlab_prog/access-multiple-elements-of-a-nonscalar-struct...

9 years ago | 0

| accepted

Answered
max_product that t takes v as vector and n as positive integer
*Method one: |slidefun|:* Download Jos' excellent FEX submission <https://www.mathworks.com/matlabcentral/fileexchange/12550-sli...

9 years ago | 0

| accepted

Answered
How can I quickly compare sizes of two Matrices?
Use <https://www.mathworks.com/help/matlab/ref/size.html |size|>'s optional second input to pick which dimension you want to che...

9 years ago | 1

| accepted

Answered
I have to find multiple series of numbers in a single matrix.
This is easy using <https://www.mathworks.com/help/matlab/ref/diff.html |diff|> and <https://www.mathworks.com/help/matlab/ref/a...

9 years ago | 0

| accepted

Answered
How to replace commas with periods in data?
<https://www.mathworks.com/matlabcentral/answers/302783-default-decimal-seperator-comma-instead-of-dot> <https://www.mathwork...

9 years ago | 0

| accepted

Answered
How to create .png files having same file name as the .dat file from which I'm writing the code?
Use <https://www.mathworks.com/help/matlab/ref/fileparts.html |fileparts|>: [fpth,fnm] = fileparts(original_name); new...

9 years ago | 1

| accepted

Answered
problem with extra entries in a matrix!
for l = 1:year % one iteration for nbrrepetiton = 0:l % two iterations for NoYes = [0 1] % two iteration...

9 years ago | 0

| accepted

Answered
How to use link exchange functions
Onto the MATLAB search path: <https://www.mathworks.com/help/matlab/matlab_env/what-is-the-matlab-search-path.html>

9 years ago | 0

| accepted

Answered
How to create image file with two variable values as the filename?
The best way to do this is to use <https://www.mathworks.com/help/matlab/ref/sprintf.html |sprintf|>, just like you were doing f...

9 years ago | 1

| accepted

Answered
How to merge two sets of data?
Simpler: >> A = [10,1]; >> B = [100,1]; >> C = [A;B] C = 10 1 100 1 Note that these kind o...

9 years ago | 0

Answered
How can i solve In an assignment A(:) = B, the number of elements in A and B must be the same error.
fc = 250; fs = 550; t = -1:0.01:1; x = -1:0.01:1; c = cos(2*pi*fc*t); % Use indexing, not a loop: y = zeros(...

9 years ago | 0

| accepted

Answered
Problem getting error while trying to save .mat file in every folder
You need to tell MATLAB the absolute or relative path of the directory where you want to save those files, something like this (...

9 years ago | 0

| accepted

Answered
How to generate sequence numbers
>> N = diff(find([1;diff(A)~=0;1])); >> cell2mat(arrayfun(@(n)(1:n).',N(:),'uni',0)) ans = 1 2 3...

9 years ago | 0

| accepted

Load more