Answered
Make an empty array stay the same size
It's really unclear what you're trying to do. Note that an empty array cannot contain anything, that's the definition of empty! ...

8 years ago | 1

| accepted

Answered
How to write a function with a for loop
What's stopping you from trying? You'll quickly find out that it errors. t = zeros(imax); or probably better t = ze...

8 years ago | 0

| accepted

Answered
How do I use nested functions to share variables? (Detailed code included)
What prevents you from passing |data_matrix| and |speed1| to the function the same way you pass |n| and |m|? That's the simplest...

8 years ago | 0

Answered
How to extract formatted hex data from a text file?
How about: filecontent = fileread(yourfile); %read everything at once hexstrings = regexp(filecontent, '(?<=Value: \[)[...

8 years ago | 0

| accepted

Answered
My matlab code is giving me this error "Too many outputs requested". If someone can help me solve this?
Your code assumes that |O| contains one and only object but never checks that. If |O| contains more than one object , you'll get...

8 years ago | 0

Answered
Using importdata function without importing the first line of text file
_is there anything I have missed?_ Yes, the |data| field of your |filename| structure, which as indicated in your screenshot ...

8 years ago | 0

| accepted

Answered
How to delete repeated values in a vector as well as values in its corresponding vector
I don't know about your code, but this will be a lot more efficient than what you're trying to do: repeats = diff(n_vect...

8 years ago | 1

| accepted

Answered
Finding files WITHOUT a specfic prefix (or suffix, extension, etc.) using dir
No, the filtering capabilities offered by |dir| are fairly limited. If you want to exclude some pattern, you'll have to get the ...

8 years ago | 1

| accepted

Answered
bsxfun(minus) vs normal minus
In your loop, which as James pointed out, wouldn't do anything useful since it overwrites |Result2| at each step, for each |i|, ...

8 years ago | 0

Answered
Reapeting same line with different coordinates
If I understood correctly, all you need to do is B = A; B(:, 1) = 25;

8 years ago | 0

| accepted

Answered
How to find specific function changes / run code as old version of Matlab without redownloading old version of Matlab (specifically tables in 2018a -> 2015a)?
The only way to get a changelog is to trawl through the <https://www.mathworks.com/help/matlab/release-notes.html release notes>...

8 years ago | 1

| accepted

Answered
Error "Invalid or deleted object." when close a GUI in App Designer
I'm not convinced of the wisdom of having a never ending loop in your |startupFcn|. Anyway, the problem is simple when you cl...

8 years ago | 0

| accepted

Answered
Avoid loop for equality
*Do not number variables*. Creating variables A1, A2, ... is a bad idea, it will make for slow, hard to understand and difficult...

8 years ago | 1

Answered
Write data .txt format with different vector in different column
A loop is a waste of time: fid = fopen('MyFile.txt', 'wt'); fprintf(fid, '%d %d\n', [A; B]); fclose(fid); This ass...

8 years ago | 2

Answered
Index in position 2 exceeds array bounds (must not exceed 1) ??
The error occurs because the vector “Is” is a 4-by-1 column vector (not a 1-by-4 row vector) so that the valid element positions...

8 years ago | 8

| accepted

Answered
Array of hexa not Displaying Values Greater than 9
Most of your code is completely pointless. If all you want to do is xor the bits of your two chars there's absolutely no point i...

8 years ago | 1

| accepted

Answered
How do I get the prior figure handle?
The simplest way to get the prior figure handle is to save that figure handle when you create that prior figure. hfig = fig...

8 years ago | 1

Answered
Select subset of dataset.
To separate the matrix in different cells of a cell array based on the value of the second column: [~, ~, id] = unique(your...

8 years ago | 0

Answered
How can i select certain elements from a vector and set them to zero?
_It has worked with the Code below and without a loop_ This is indeed the way to do it. I would recommend one change though: ...

8 years ago | 0

| accepted

Answered
How count NaN values and replace NaNs in a sequence with that number?
I don't think it's entirely possible to do it without a loop, but the loop can be limited to the number of sequences (3 steps in...

8 years ago | 1

| accepted

Answered
count the change between a row and the next, in a column
Hum, unless I'm very mistaken, wouldn't the simplest solution be to convert the array to double, then |nnz(diff())| that? %...

8 years ago | 0

Answered
convert hex data to viewable image(JPEG) in matlab
Clearly, you have absolutely no idea what you're doing. A quick search of the first few bytes of your hexadecimal stream reve...

8 years ago | 0

Answered
what %f\n means in fscanf(...,%f\n) ?
As explained in the <https://www.mathworks.com/help/matlab/ref/fscanf.html#bt_j35z-1-formatSpec documentation of |fscanf|>, it s...

8 years ago | 0

| accepted

Answered
how to unnest cell array
yourvariable = yourvariable{1};

8 years ago | 0

Answered
Remove for loop and reduce time
Points for using |discretize| instead of writing your own loop for that. The thing is, what you really want is the histogram and...

8 years ago | 1

| accepted

Answered
calculate the percentage of B&W image
percentageWhite = nnz(yourimage) / numel(yourimage); <https://www.mathworks.com/help/matlab/ref/nnz.html |nnz|> gives you t...

8 years ago | 2

Answered
Catching Matlab state variables in the try-catch MException.
Unfortunately for you, when an exception is thrown by a function and that exception is not caught within the function, all the l...

8 years ago | 0

| accepted

Answered
Set size of array in object through input?
classdef SomeClass properties (SetAccess = private) Array = []; end methods function this ...

8 years ago | 0

| accepted

Answered
I need to plot a surface plot from given X and Y coordinate matrixes and z as a constant value.
Why do your X and Y have two columns if it means nothing? X = 0:3; Y = 0:3; Z = 0; [XX, YY] = ndgrid(X, Y); sur...

8 years ago | 0

| accepted

Load more