Answered
Game of Life - my elements don't die, only grow!
Have a closer look at your logic operations: neighbours(row,col)==2||3 which is not an _error_, but it does not do what ...

9 years ago | 2

| accepted

Answered
My code creates files, uses them and then deletes them. The deletion part does not always work
Sometimes pausing helps, because OS operations do seem to take a finite amount of time: delete output.txt pause(1) rm...

9 years ago | 0

Answered
Question about logical calculation in matrix
Just use <https://www.mathworks.com/help/matlab/ref/accumarray.html |accumarray|>: >> AA = [0.2,1;0.3,1;0.5,2;0.9,2] AA ...

9 years ago | 1

Answered
When numerical data type changes while assigning new data?
_"Why is the behaviour different depending on the matrix size?"_ It doesn't, and there is nothing astonishing happening at al...

9 years ago | 2

| accepted

Answered
How to use multiple struct files using for loop
*Always |load| into a variable, then you avoid this problem entirely*. Assuming that your |.mat| files contain the same field...

9 years ago | 1

Answered
I need to display the max value in this function.
Rather than enlarging the array on each iteration as KSSV showed (and in general is <https://www.mathworks.com/help/matlab/matla...

9 years ago | 1

Answered
What kind of formula is that?
It is just the vector length, aka magnitude: <https://en.wikipedia.org/wiki/Euclidean_vector#Length> Note that the code us...

9 years ago | 0

| accepted

Answered
How to plot a new data sets on a figure window which has been created in previous m-file ? (the figure has two subplot)
By far the easiest solution to this is to obtain and use the axes handles explicitly. Then your task is trivially easy: ax1...

9 years ago | 0

| accepted

Answered
Finding column and row number of a element in array
>> A = [1,2,3;4,5,6;7,8,9] A = 1 2 3 4 5 6 7 8 9 >> [val,idx] = max(A(:)...

9 years ago | 1

Answered
I nee to change this str2double code while keeping the same output for my collatz function.
str = input('Enter an integer greater than 1:','s'); num = sscanf(str,'%i'); Although |str2double| has the advantage tha...

9 years ago | 0

| accepted

Answered
How can I perform arithmetic operations with RGB values?
_"What I understand is that I cannot treat RGB values as general numeric entities."_ Yes you can. The fact that your data are...

9 years ago | 0

| accepted

Answered
How can I increase my vector by increments of 100 but end on 558?
Like this?: >> val = 558; >> vec = 0:100:val; >> vec = [vec,val(vec(end)~=val)] vec = 0 100 200 300 ...

9 years ago | 0

| accepted

Answered
Creating dummy variables from categorical variable
Vectorized: >> vec = [1,1,5,7,7]; >> [~,~,idc] = unique(vec); >> siz = [numel(idc),max(idc)]; >> out = zeros(s...

9 years ago | 1

Answered
Problem with printing exponents with multiple digits
In LaTeX use |{}| to group characters together: title('x vs x^{10}') <https://www.mathworks.com/help/matlab/creating_plo...

9 years ago | 1

| accepted

Answered
How can I download the PDF documention for MATLAB?
Here is the main MATLAB help page: <https://www.mathworks.com/help/matlab/> On the right-hand side there is a link labeled...

9 years ago | 0

| accepted

Answered
reshape a matrix from the text
A simple way to get the numeric data in one array is to use <https://www.mathworks.com/help/matlab/ref/textscan.html |textscan|>...

9 years ago | 1

Answered
I need help determining and displaying the number of steps it takes to complete this loop when any integer is entered.
You just need to add a counter variable, here I used |cnt|: str = input('Enter an integer greater than 1: ','s'); num = ...

9 years ago | 0

| accepted

Answered
Recursively create structure fields or (maybe) cell2struct
You might be interested in reading about non-scalar structures: <https://www.mathworks.com/help/matlab/matlab_prog/access-mul...

9 years ago | 3

Answered
How to check whether a 2d matrix is gradually increasing in values in row direction.
Using <https://www.mathworks.com/help/matlab/ref/cummax.html |cummax|> is simple: >> A = [2,4,7;3,4,6] A = 2 4 ...

9 years ago | 2

| accepted

Answered
How do I modify the assignment of an array in a specific dimension?
Indexing out of variable using |()| and |{}| are just shorthand for the function <https://www.mathworks.com/help/matlab/ref/subs...

9 years ago | 1

| accepted

Answered
getting prime numbers between 2 numbers input by the user
When you read the <https://www.mathworks.com/help/matlab/ref/primes.html |primes|> documentation it describes that the function ...

9 years ago | 2

| accepted

Answered
How make this matrix using for loop?
Why use a loop? >> M = zeros(10,14); >> M(1:2:end,1:5) = -tril(ones(5)); >> M(2:2:end,1:5) = +tril(ones(5));

9 years ago | 0

| accepted

Answered
How to convert a numeric string into a numeric range?
function out = str2vec(str) vec = sscanf(str(2:end),'%f%c'); out = []; idb = 1; ide = 1; while idb<=numel(vec) ide = i...

9 years ago | 4

| accepted

Answered
what does this line of code mean,
The line of code C{k} = xlsread(name) reads the file with filename |name|, and puts any numeric data into the |k|-th cel...

9 years ago | 0

| accepted

Answered
How can i replace every second sample with the previous sample in an audio file of format .wav?
Assuming that you have use <https://www.mathworks.com/help/matlab/ref/audioread.html |audioread|>, and have an MxN matrix (for N...

9 years ago | 0

Answered
Why is MATLAB officially written with capitalized letters?
Because it is such a _capital_ product.

9 years ago | 1

Answered
How can I find the cumulative sum of a vector without using the cumsum funtion or any loops
>> A = [4,-2,6,1,2]; >> sum(triu(A(:)*ones(1,numel(A))),1) ans = 4 2 8 9 11 >> cumsum(A) ans = ...

9 years ago | 1

Answered
Hi, I have a problem with a script given to me by my teacher , I don't know what is its point nor its problem
The function reads |.CSV| files into a numeric matrix. It uses a very awkward |while| loop to append leading zeros to the filena...

9 years ago | 1

| accepted

Answered
Index exceeds matrix dimensions.
Because you are trying to access some part of an array _that does not exist_. Just like this: >> A = rand(4,3,2); >> A(:...

9 years ago | 0

Load more