Answered
i want a randomly scramble of a divided image into 4 blocks
img = uint8(((0:255) + (0:255).') / 2); % Test image s = size(img); % Split image to blocks: img4 = reshape(img, s(1) ...

5 years ago | 0

Answered
My array has about 15,000,000 indices, however error "Index in position 1 is invalid. Array indices must be positive integers or logical values." shows up
The exponential notation appears in the command window only. You can influence this by the command format. Internally the number...

5 years ago | 1

Answered
How to find the 18th steady-3 number ?
Let's assume the problem can be solved in Matlab without high precision toolboxes. Numbers can be represented exactly up to 2^53...

5 years ago | 0

Answered
Finding areas of data based on value threshold and contiguous size, both height and length.
Start with: B = (A > 3); 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

5 years ago | 0

Answered
Why ist my variable allocation so slow?
Do not overestimate the accuracy of the profiler. Sometimes the END uses a lot of time in a FOR loop, although no work is done t...

5 years ago | 1

Answered
Too many Input Arguments Error
This means, that your B.Perimeter is not a scalar. Do you mean: % Was: circu=[B.Perimeter.^2] ./(4*pi*[B.Area]); circu=...

5 years ago | 2

Answered
Problem with matrix indexing
The CPU time of the reshape command is very tiny, because it only checks if the number of elements is not changed and then it re...

5 years ago | 1

| accepted

Answered
What MATLAB functions are underappreciated?
dbstop . Many newcomers mention, that they do not understand, what their code does. The possibility to step through it line by l...

5 years ago | 2

Answered
How to creat a pairwise comparison matrix using a for loop ?
A=[2 3; ... 4 7; ... 5 4; ... 2 1]; idx = nchoosek(1:size(A, 1), 2); B = A(idx(:, 1), :) - A(idx(:, ...

5 years ago | 1

| accepted

Answered
Save error on linux
Does the folder "/project/XXX/XXX/LTC/ACO/Realistic_ins/" exist? Mounting a folder "/project" directly as root folder is very un...

5 years ago | 0

Answered
Suppress contourm figure window
The HandleVisibility manages the visibility of the handle for searching with e.g. findall. This does not mean the optical visibi...

5 years ago | 0

Answered
creating a GUI with edit box and push button
Omit the brute clearing header clc;clear all; close all; It is a waste of time, kills other windows, and has not serious benef...

5 years ago | 0

Answered
Errors while reading binary data files
The problem is hidden here: fid = fopen(file, 'rt'); This opens the file in "text"-mode on Windows. Then e.g. a CHAR(8) is con...

5 years ago | 1

| accepted

Answered
How to draw a rectangle over a patch?
You can draw into different AXES objects, while the top one is invisible: FigH = figure; Axes1H = axes(FigH, 'XLim', [0, 100...

5 years ago | 0

| accepted

Answered
Dot indexing is not supported for variables of this type.
Replace: strfind(sorted_cell_array_of_folder_names(i).name,'.'); % by strfind(sorted_cell_array_of_folder_names{i},'.'); The...

5 years ago | 0

| accepted

Answered
When is output assigned from function?
Your first version is fine. When the function myfun() exists, the contents of A is replied as first output. The value of B is no...

5 years ago | 0

Answered
how to make it into for loop
iPeak = 0; % [EDITED] for k = [0, 3, 6, 9] name = sprintf('%d.txt', k); data = load(name, '-ascii'); iPeak = iPeak +...

5 years ago | 0

| accepted

Answered
Different results for formula in Matlab and Excel
It looks, like you have a typo in the code you have typed in Excel.

5 years ago | 0

Answered
How to save multiple figures with specific figure name in a certain directory ?
Ah, I see: print([destination,num2str(base),'-dpng','-r2000']); % ^ End of file...

5 years ago | 0

| accepted

Answered
How to go about programming this function in MatLab
function c = YourSum(x, y, a, b) c = sum(sqrt((a - x).^2 + (b - y).^2)); end

5 years ago | 0

Answered
How do I fit a damped sine wave to my data?
x = csvread('PH 1140 - 3R (1,1) - Sheet1.csv'); y = csvread('PH 1140 - 3R (1,2) - Sheet1.csv'); plot(x, y); hold on; This is...

5 years ago | 2

| accepted

Answered
Error: Matrix dimensions must agree
Seriously? Your code contains some jokes: -1/.5 == 2 kron(eye(32), [-2, 0; 1, 0]) .* ones(64, 1) == kron(eye(32), [-2, 0; 1, 0...

5 years ago | 0

| accepted

Answered
Finding the index of duplicate rows in a cell
A = [3,8; 8,9; 8,9; 3,9; 3,9; 3,5; 5,10; 5,10; 3,10; 3,17; 3,17; 11,17; 10,11; 10,11; 3,10]; B = {[3,8;8,9;9,3]; [3,5;5,10;3,10...

5 years ago | 0

| accepted

Answered
Cernter of gravity.
I assume you mean the center of mass. A matrix is an rectangular set of numbers. So should we assume, that the values of the mat...

5 years ago | 0

Answered
Array indices must be positive integers or logical values.
The error message means, that in F(i), the i has its default value, which is the imagninary unit. As Weixin Wang has mentioned ...

5 years ago | 1

| accepted

Answered
How to find the row and column for a value within a matrix [c] nearest or equal to 700.
find(inputMat (closest(700))) This is pure guessing. Notice that a command like closest(X) cannot even work in theory, because ...

5 years ago | 1

Answered
Not Enough Input Arguments
"when you click the Run button in the future" - This means, that you tried to run the programn pressing the green triangle, the ...

5 years ago | 0

Answered
How can I build my own randi function from scratch?
What exactly is "from scratch"? Which tools are included, which one are excluded? E.g. where do you want to take your random bit...

5 years ago | 0

Answered
How would I perform logical comparisons with times given in the form of a string vector?
Are you sure that this is working: temptime = IE322data{:,3}; What is the contents of IE322data ? The command works only, if t...

5 years ago | 0

Answered
Separate correctly values in array
A = [7.046, 15.66, 24.16, 31.476, 39.42, 62.86, 69.83, 91.326, 98.586,106.672, 114.722]; B = [0.53, 1.25, 2.01, 2.78, 3.51, 4.2...

5 years ago | 0

| accepted

Load more