Answered
trying to do 1D convolution without using inbuilt functions.
You defined a variable |K|, and then tried to use |k|. MATLAB is case sensitive, you cannot use upper/lowercase interchangeab...

10 years ago | 0

| accepted

Answered
Convert Matrix to specified format as a text file to be read in Xilinx
Here is one way: N = 256; % length of each row X = reshape(1:N^2,N,N).'; % fake data % define the text format of each...

10 years ago | 1

| accepted

Answered
finding the divisors for a number displaying the divisors between two numbers.
See this question: <http://www.mathworks.com/matlabcentral/answers/21542-find-divisors-for-a-given-number> >> N = 84...

10 years ago | 0

| accepted

Answered
Why doesn't this code have a recursion error?
You changed this: if any(X(:) == 0) into this: if any(X(:) > 0) Think about it. PS: MATLAB includes a <http://w...

10 years ago | 0

| accepted

Answered
Tying to find positive numbers in a matrix and have the location displayed as well?
>> A=[3 -5 0; -9 2 4; -2 -1 2]; >> idx = A>0; >> [R,C] = find(idx) R = 1 2 2 3 C =...

10 years ago | 0

| accepted

Answered
How to make one element in a matrix the same for other elements?
>> x = 1; >> y = 2; >> N = 4; % size of the matrix >> A = eye(N) * x; >> A(1+1:1+N:end) = y; >> A(1+N:1+N:end) ...

10 years ago | 0

| accepted

Answered
Meaning of x = X(training(c,1),:);
Why not use the power of the internet to learn how MATLAB works? I used [an internet search engine] to search for "MATLAB colon"...

10 years ago | 0

Answered
x = X(training(c,1),:);
|X| is not a function, it is a variable. I explained this in my answer to your other question: <http://www.mathworks.com/m...

10 years ago | 0

Answered
how to convert timestamps to number of seconds
What do you mean by _"number of seconds"_ ? The number of seconds _from when_? From what <https://en.wikipedia.org/wiki/Epoch_(r...

10 years ago | 0

| accepted

Answered
Vector giving weird multiplication
The problem is very simple: |x| has <http://www.mathworks.com/help/matlab/characters-and-strings.html character class>, it is no...

10 years ago | 0

| accepted

Answered
how to add some value to random matrix with specific condition?
A = [ 1 2 0 2 1 1 3 1 1 ] % N = max(sum(1+A,2)); C = arrayfun(@(n){[ones(1,n),0]},A); C = cellf...

10 years ago | 0

Answered
How can I make a logical array by comparing two date vectors?
You could use |ismember| with the |'rows'| option. It only takes two steps # convert all of the dates into datevectors (not d...

10 years ago | 1

| accepted

Answered
I'm scripting & getting a error "Error using * Inner matrix dimensions must agree." Please help me debug this.
Probably you used the <http://www.mathworks.com/help/matlab/ref/mtimes.html |mtimes *|> operator when you actually should have u...

10 years ago | 0

Answered
define function that includes number of variable and call it in many callback function in GUI
Note that _avoiding_ using |evalin| (or |assignin|, etc) has numerous advantages: it is faster, it does not overwrite preexistin...

10 years ago | 1

Answered
how to convert 24bit of bmp image to 8 bit?
Here is the official MATLAB answer: <http://www.mathworks.com/matlabcentral/answers/93196-how-do-i-convert-a-24-bit-depth-ima...

10 years ago | 0

| accepted

Answered
How to prompt user to input a folder containing images so that we can process all images inside folder?
A neat and simple solution is to use <http://www.mathworks.com/help/matlab/ref/uigetdir.html |uigetdir|>.

10 years ago | 0

Answered
Rectangle appears outside axes when zooming
You might need to set the |Clipping| for both the <http://www.mathworks.com/help/matlab/ref/rectangle-properties.html rectangle ...

10 years ago | 0

Answered
csvread file containing text
The solution is very simple: use <http://www.mathworks.com/help/matlab/ref/textscan.html |textscan|> instead. |textscan| works w...

10 years ago | 1

| accepted

Answered
How Can I Take Samples from a Matrix Randomly?
Try this: >> idx = ~ismember(matrix(:,1:2),train(:,1:2),'rows') >> test = matrix(idx,:) It compares only the first tw...

10 years ago | 1

| accepted

Answered
How can I add or subtract any given matrix value with its following value?
>> vec = [1,2,3,6,8,0]; >> vec(1:end-1)+vec(2:end) ans = 3 5 9 14 8 or using your example: ...

10 years ago | 0

| accepted

Answered
Subplot with odd number of plots
Here is some simple code that adjusts the position without using any hardcoded values: it centers the last axes based on the pos...

10 years ago | 8

Answered
Error when I concatenated matrices
This error can occur whenever any of the elements of |R| are column vectors or matrices: >> R = {[1;2;3;4],[5;6]}; >> m ...

10 years ago | 0

| accepted

Answered
Generate the same random number stream with for and parfor loop
You can't, because the |parfor| execution order is not specified. The easiest way to avoid this problem would be to generate ...

10 years ago | 1

| accepted

Answered
How to build a matrix with specific entries?
>> N = 10; % size of matrix >> lambda = 3; >> A = eye(N) * (1+2*lambda); >> A(1+1:N+1:end) = -lambda; >> A(N+1:N+1...

10 years ago | 0

| accepted

Answered
How to split a cell array?
*Option One: Convert to Numeric* >> mat = [sscanf(Z{1},'%f'),sscanf(Z{2},'%f')].' mat = 1.1000 2.1000 3.200...

10 years ago | 2

| accepted

Answered
How can i convert multiples lines into 1 text string (big block)
To remove *all* whitespaces within the text: str = regexprep(fileread('temp.txt'),'\s+','') Or to only remove newlines a...

10 years ago | 1

Answered
Exporting specific elements alone from a text file
If the file has a fixed column-structure, with mixed string and numeric data, then you can use <http://www.mathworks.com/help/ma...

10 years ago | 0

Answered
Round saved variables (not command line output) to 5 decimal places
MATLAB has not eaten your digits, you just need to change the <http://www.mathworks.com/help/matlab/ref/format.html |format|> to...

10 years ago | 0

| accepted

Answered
Read m file with fgets / fgetl
*Solution* Use |fgetl| and this: fprintf(Fout,'%s\n',line); *Explanation* there is a very large difference between these...

10 years ago | 0

| accepted

Answered
Moving average - for loop vectorization
To efficiently calculate a moving average you should use <http://www.mathworks.com/help/matlab/ref/conv.html |conv|>, something ...

10 years ago | 1

| accepted

Load more