Answered
Only clear the variables in for loop
It is rarely useful to clear variables in the workspace. In many cases this decreases the speed. Prefer a proper pre-allocation,...

8 years ago | 1

| accepted

Answered
How to open .mexw64 file with Matlab?
You do not "open" such a file, because it is a compiled function. You call it exactly as any other Matlab function. Why do yo...

8 years ago | 0

Answered
Why plot is over plotted?
x = 1:10; % No need for square brackets y = sin(x); for k = 1:10 % NextPlot='add' is the same as "hold on" A...

8 years ago | 0

| accepted

Answered
Error using datevec (line 212) Failed to lookup month of year.
Xgridndx = 40; Ygridndx = 82; fnames = dir('HFc20*.mat'); ucurrent = []; vcurrent = []; t = []; for...

8 years ago | 0

| accepted

Answered
passing uicontrol objects to uicontrol callbacks
You can use one callback for all 3 radio buttons: handles.p = uipanel; handles.slider(1) = uicontrol(p, 'Style', 'slider...

8 years ago | 1

Answered
Why I get this error message? How figure can be corrupt?
The file is corrupted. There is no chance that the forum can fix the problem for you. You have to restore the former version...

8 years ago | 0

Answered
How to calculate a value from the first row in a Matrix?
Remember that |size(A)| replies a vector. Then |1:size(A)| is not clear, although it is not an error. Prefer |size(A, 1)| if you...

8 years ago | 0

| accepted

Answered
speeding up fread for true 12bit data
Read the data as bytes at first: data = fread(mraw_file, inf, 'uint8=>uint16', machinefmt); pad = ceil(length(data) / 3...

8 years ago | 0

| accepted

Answered
WHAT'S THE ALGORITH APPROACH FOR THE BELOW CODE?
The code classifies the RGB colors of pixels, most likely to identify the color codes on a resistor. The code is poorly comm...

8 years ago | 0

| accepted

Answered
After Installation, Matlab 2018a does not open any files
The installation failed. I'd try an uninstall + reinstall. If you get the same problems, download the software again. If the pro...

8 years ago | 0

Answered
Alternatives to using eval/evalc for running a file?
If you have defined the name of the script to run as a variable, use the |run()| command. See <https://www.mathworks.com/help/ma...

8 years ago | 0

| accepted

Answered
Why the loop result is incorrect?
Remember, that Matlab works with the type |double|, which is a floating point type according to IEEE754. If you define a variabl...

8 years ago | 0

| accepted

Answered
why when i run code this error fv(:,1) = funfcn(x,varargin{:}) ?
Provide the function handle to the existing function as 1st input to |fminsearch|. Using a char vector is allowed for backward c...

8 years ago | 1

Answered
xticklabels function for more than 11 labels ?
It is smarter to avoid the hard coding to set the names of the months, but to use |datetick| to display the names dynamically an...

8 years ago | 1

| accepted

Answered
Save images in a loop
See: * <https://www.mathworks.com/matlabcentral/answers/57446-faq-how-can-i-process-a-sequence-of-files FAQ: How to process a...

8 years ago | 0

| accepted

Answered
I want to write a matlab programme to compute the sum of the digits in my cellphone number with a value larger than 5, using for and if loops. How do I do it?
Start with reading the "Getting Started" chapters of the documentation. It is impossible to work efficiently with Matlab without...

8 years ago | 0

Answered
Why can't I write my Matlab file to microsoft word?
As explained in the documentation |save| created binary MAT files and for matrices it can create text files also, if you specify...

8 years ago | 0

| accepted

Answered
Mapping arrays of different dimensions
A(:,:,1) = [1 2; 3 4] A(:,:,2) = [5 6; 7 8] i = [1 1 1 2 2]; j = [2 2 2 2 2]; k = [1 1 2 2 1]; index = sub2ind(...

8 years ago | 0

| accepted

Answered
modify only the diagonal entries in a matrix?
A = rand(4,3); s = size(A); index = 1:s(1)+1:s(1)*s(2); % Indices of the main diagonal A(index) = A(index)...

8 years ago | 1

| accepted

Answered
creating array with greatest variety of numbers
If you want |num| vectors with a great "variability" taken from the set of permutations with |n| elements taken from |1:k|: ...

8 years ago | 0

| accepted

Answered
Append element to a cell
The message means, that |X| does not have either |i| rows or not |2| columns. You can check this easily using the debugger. Type...

8 years ago | 0

Answered
use hold on to create a plot with many doubles
The main idea is to avoid hiding indices in the names of variables. See <http://www.mathworks.com/matlabcentral/answers/304528-...

8 years ago | 0

Answered
Rectify the error in imread
Do not work with relative paths and it is a bad idea to add folders to the path, because it can confuse Matlab substantially, if...

8 years ago | 1

Answered
What is the definition and operation of [row,col]
It depends on what "row" and "col" are and on the context: row = 2; col = 3; x = [row, col] % a [1 x 2] vector w...

8 years ago | 0

Answered
Different ways of creating .mat files? what is an array, cell, structure, string?
There are no different ways to create MAT files, but only one way: the |save| command. See: doc save There is no specifi...

8 years ago | 0

Answered
How to get the string from popup menu in matlab GUI ?
The error message is clear: |allitenms1| is not a cell. So use the debugger to check, what it is instead. Type this in the comma...

8 years ago | 0

Answered
How to add minimize tool button in GUI ?
function main Gui.FigH = figure; Gui.AxesH = axes; Gui.ButtonH = uicontrol('Style', 'ToggleButton', 'Value', 1, ...

8 years ago | 0

| accepted

Answered
Count conservative occurrences of zeros and if zero appeared for defined number of times it should be changed.
If you want to replace the 2nd element after a 1 by -1, if it was a 0 before: A = double(rand(10, 5) < 0.3); % Some test ...

8 years ago | 0

| accepted

Answered
How can I match axis values with data?
If you do not specify the X-values of the data, Matlab assume, that they are |1:length(data)|. Example: data = rand(1, 10)...

8 years ago | 1

| accepted

Load more