Answered
What the difference between using bracket and not.
None of the answers explain why this works, nor even mentioned the useful-to-know name of this syntax. The actual reason is bec...

6 years ago | 5

| accepted

Answered
Create a 1 x m Structure instead of a 1x1 Structure
S = struct('FirstField',num2cell(1:100), 'SecondField',num2cell(1:100))

6 years ago | 2

| accepted

Answered
Function implementation in matlab
>> a = 0.9; >> V = 0:40; >> M = a.^(V+V(:)); % requires >=R2016b For earlier versions replace the + with bsxfun.

6 years ago | 0

Answered
How to find all the combinations of a vector elements whose sum is equal to a given number
A simple recursive nested function, with short-circuiting for combinations whose sums are greater than N (this makes the whole t...

6 years ago | 0

| accepted

Answered
Sum and Difference across row and column
>> sum(A(:,2))-A(2,1)-A(2,3) ans = -0.19880

6 years ago | 0

| accepted

Answered
how r to each Matlab folder
cd :\E % incorrect (what you wrote) cd E:\ % correct (what you should do)

6 years ago | 0

| accepted

Answered
How does clearing nested function workspace works?
I have use nested functions extensively for many years, and have also been curious about this behavior. As far as I have found, ...

6 years ago | 1

| accepted

Answered
showing unit using fprintf
fprintf and sprintf do not generate formatted text based on markup (like LaTeX or XML). Their output is pure text, and pure text...

6 years ago | 0

| accepted

Answered
sprintf naming of figures
The closing parenthesis is in the wrong place: sprintf('S10_AHAPlot_%s_%s_%s_R%u.fig', order(k), orderS(y)), Observer, Rep; % w...

6 years ago | 0

| accepted

Answered
How to assign values to a column in each row where the column number for each row is specified in a vector?
Use sub2ind like this: >> A = zeros(2,2); >> idc = [2,1]; >> idx = sub2ind(size(A),1:numel(idc),idc); >> A(idx) = 1 A = ...

6 years ago | 0

| accepted

Answered
CSVread / dlmread not working when trying to upload a CSV file
The csvread documentation explains that the 2nd, 3rd, 4th and 5th input arguments are an offset value, and that they must be spe...

6 years ago | 0

| accepted

Answered
how does a function invoke the inputs?
MATLAB's function input and output arguments are entirely positional. Their names are irrelevant. When calling a function, you ...

6 years ago | 0

| accepted

Answered
Eliminate solutions that are a subset of another
"I am sure this has a simple solution but I can't seem to determine it." Here is one simple solution that passes your example: ...

6 years ago | 0

Answered
How can you read a filename but store a specific number within it?
D = 'path to the folder where the files are saved'; S = dir(fullfile(D,'*crop*area*.jpg')); [~,N] = cellfun(@fileparts,{S.name...

6 years ago | 1

| accepted

Answered
Find a word in a file then pick the value next to it
>> str = fileread('test.txt'); >> rgx = 'MAX_ANCRAGE_[XYZ]_(?:6881|6952|6968),\s+(\d+\.?\d*)'; >> tkn = regexp(str,rgx,'tokens...

6 years ago | 1

Answered
Is it case sensitive?

6 years ago | 1

| accepted

Answered
double summation of a matrix
By far the easiest solution is to use conv2, e.g. where S is your array: >> S = randi(255,330,332,'uint8'); >> U = conv2(doubl...

6 years ago | 0

Answered
How to create a loop that runs a function and save output through subfolders in a directory?
I replicated your file structure as I understood your explanation, it looks like this: Obviously I do not have your data file...

6 years ago | 0

| accepted

Answered
How to connect end points for different series in a line plot?
N = [0,1,2,3,4,5]; % n = ts/tau Y = zeros(1,numel(N)); % new C = cell(1,numel(N)); % new f = @(t_star,y,n) 1-y-(t_star/n); %...

6 years ago | 0

| accepted

Answered
How to convert a 1x64 size cell to a struct with 2 fields?
Where C is your cell array: S = [C{:}] https://www.mathworks.com/help/matlab/matlab_prog/comma-separated-lists.html https://w...

6 years ago | 0

Answered
comparing between two identical variables returns logic 0?
"as you can see in the command window bk(6) equals ak(2)" Nope. Just looking at some floating point values displayed in the com...

6 years ago | 0

| accepted

Answered
Creating several structures within another structure
MATLAB does not limit how much nesting you can do with any container arrays. tubing.nodes = struct('X',1); tubing.elements = s...

6 years ago | 0

| accepted

Answered
how to put an overline for \alpha_{KZ}
ylabel('$\overline{\alpha_{KZ}}$','interpreter','latex')

6 years ago | 1

Answered
How to change the field width of an exponential notation?
Given >=2 digits, ensure >=3 digits: >> val = 3.45866636216603e2; >> str = sprintf('%.14e',val) str = 3.45866636216603e+02 ...

6 years ago | 0

| accepted

Answered
how do i delete questions?
You need to call the function with all of its output arguments, e.g. (pick the names to suit your needs): [A,B,C,D] = DiagDom()...

6 years ago | 0

| accepted

Answered
How to store multiple arrays into a single one?
Use a cell array: C = {array_1,array_2} https://www.mathworks.com/help/matlab/matlab_prog/access-data-in-a-cell-array.html

6 years ago | 0

| accepted

Answered
Trying to graph function giving me an incorrect scale
"....but am I multiplying something wrong?" Yes: you used matrix operations, whereas you need to use element-wise array operati...

6 years ago | 2

Answered
My variable are not being recognized or are stuck inside of the loop
Do NOT call input inside your functions (nor for that matter, have any user interaction, file import/export, etc.). You need to...

6 years ago | 0

| accepted

Answered
Inserting matrices in a cell - in a for loop
You need to get the data out of the cell array before concatenating it with the new data, i.e. replace wholedff{c_event} = [who...

6 years ago | 0

| accepted

Answered
Nested if else statements
Badly indented code hides bugs. Your code is badly indented. Your badly indented code hides the bug that causes that error mes...

6 years ago | 1

Load more