Answered
How to assign values of each sub matrix from main matriix into another matrix?
Assuming that the number of input matrix rows/columns are exact multiples of the number of submatrix rows/columns, then this doe...

8 years ago | 0

| accepted

Answered
Does passing large structures, such as a GUI handles structure, to a function increase execution time?
_"In essence I often find when building GUI's that large amounts of my code are replicated and therefore I try to write function...

8 years ago | 1

| accepted

Answered
Loop in all scripts
This line of code inside the loop: handles.data = data; completely replaces the field |data| on each loop iteration: on ...

8 years ago | 0

| accepted

Answered
How to multiply each element separately from row first to next row in matrix?
Simpler: M = [1,2,3;4,5,6;7,8,9]; P = 1; for k = 1:size(M,1) P = P .* M(k,:); end Giving: >> P P...

8 years ago | 1

Answered
How to fix error using accumarray, the function '@(x)x(max(Ac(x,2))==Ac(x,2))' returned a non-scalar value.
One simple way is to use |sortrows|, |unique|, and indexing: >> Ac = sortrows(Ac,2); >> [~,idx] = unique(Ac(:,1),'last')...

8 years ago | 0

| accepted

Answered
How to use Variables in movefile or copyfile ?
copyfile(A,B) |[]| is a concatenation operator, so when you do |[A,',',B]| you form *one* char vector with the contents of ...

8 years ago | 1

| accepted

Answered
Average and error bars in Matlab for a complex array
MA=mean(A,4) _"Is this correct?"_ Yes.

8 years ago | 0

Answered
how to delete rows with some repeated elements?
One way using <https://www.mathworks.com/help/matlab/ref/sortrows.html |sortrows|> and <https://www.mathworks.com/help/matlab/re...

8 years ago | 0

| accepted

Answered
Precision problem reading from excel?
I suspect that Excel (in the typical way of Microsoft) is doing some magic to prevent people from trying to enter numbers that h...

8 years ago | 3

Answered
nested function problem solving
This is how you define the function |totaloutflow|: T=totaloutflow(x,N) It has two input arguments, both of which are re...

8 years ago | 0

Answered
Combine 2 char vectors
A slightly different approach: >> A = 'IMDOINGATEST'; >> B = 'ABCDE'; >> C = repmat(B,1,ceil(numel(A)/numel(B))); ...

8 years ago | 0

Answered
Do Matlabs 3D plots swap axes?
The confusion occurs because |X| and |Y| do not correspond to rows and columns (i.e. dimensions 1 and 2) of the plotted matrix, ...

8 years ago | 5

| accepted

Answered
How to assign parts of a main matrix equal to the indexed sub matrices?
This will work for any size matrix: cat(3,... A(1:2:end,1:2:end),... A(1:2:end,2:2:end),... A(2:2:end,...

8 years ago | 0

| accepted

Answered
How can I make a vector from a matrix?
A = A(A~=0)

8 years ago | 0

| accepted

Answered
Get difference between array values
You have a variable named |diff|. Delete that variable. You might like to check all of these: which test -all which d...

8 years ago | 0

| accepted

Answered
Replace values in each column by 0 after a pre-specified search value was found in that column
As requested, without any loop is easy in just one line of code: >> A = [1, 1; 0.5, 1; 0.5, 0.5; 1, 1] A = 1.0 1...

8 years ago | 2

Answered
I am looking for a code to identify if the entered number is odd or even. For example: "ABC 123", I would be really grateful if someone shares the code.
<https://www.mathworks.com/help/matlab/ref/sscanf.html |sscanf|> is probably the most efficient way to convert that char vector ...

8 years ago | 0

Answered
use string matrix value to matrix name
Do not access variable names dynamically, unless you want to force yourself into writing slow, complex, buggy code. Read this to...

8 years ago | 1

Answered
How can I use more than one function with inputs and outputs in a uicontrol button callback?
You question is fundamentally one of _how to pass data between callback workspaces_. As you have noticed, callback functions do ...

8 years ago | 0

| accepted

Answered
Creating a matrix whose entries are matrix
>> A = [-4 1 0; 1 -4 1; 0 1 -4]; >> I = eye(size(A)); >> Z = zeros(size(A)); >> B = [A I Z; I A I; Z I A] B = ...

8 years ago | 0

| accepted

Answered
How to store data from pushbutton within a nested function?
Add <https://www.mathworks.com/help/matlab/ref/waitfor.html |waitfor|> right at the end of the *main* function (the one that you...

8 years ago | 1

| accepted

Answered
call function in fmicon optimization failing
The <https://www.mathworks.com/help/optim/ug/fmincon.html |fmincon|> documentation clearly states that the first input _" |fun| ...

8 years ago | 0

| accepted

Answered
fun applied to a loop
function out = totalflow(x,N) out = x(1:N) + x(N+1:2*N); end and M = rand(10,3); [R,C] = size(M); T = nan(...

8 years ago | 0

| accepted

Answered
How to replace values in a cell array based on a condition?
for k = 1:numel(C) C{k}(:,8:18) = min(F{k}(:,8:18),max(G{k}(:,8:18),C{k}(:,8:18))); end

8 years ago | 0

| accepted

Answered
How to write datetime(char array 1058*19), latitude(1*1058 double) and longitude (1*1058 double) in txt file using fprintf ???
Assuming that the date-time char vectors are in a cell array: >> fmt = '%20s \t %2.2f \t %2.2f\n'; >> DT = {'2018-05-16 ...

8 years ago | 1

| accepted

Answered
How to separate groups of numbers between NaN in new variables?
>> v = [NaN NaN 1 2 3 4 5 NaN NaN 6 7 8 9 10 NaN NaN NaN NaN 11 12 13 14 15 16 17 18 NaN NaN]; >> idd = diff([true,isnan(v)...

8 years ago | 1

Answered
How can I use VideoReader to read a variable file name
The bug is clear in the error message: you supply a char vector like this: v = VideoReader('vidName'); when you should b...

8 years ago | 1

| accepted

Load more