Answered
Problem with IF statement
Don't use clear all. You don't need it. I suspect you encountered the wondrous world of floats. Computers don't have infinite...

5 years ago | 0

Answered
Old MATLAB Online Courses
The basics haven't changed (much) since then. For an incomplete overview, see this thread. You can also do the Onramp tutorial ...

5 years ago | 0

| accepted

Answered
Data fitting by non linear discrete equation.
The code below uses fminsearch, which means you don't need the optimization toolbox. The downside is that it is sensitive to a l...

5 years ago | 0

| accepted

Answered
Output only numbers with complex conjugate
a = [1+1i*0.1, 1-1i*0.1, 5-1i*0.1, 10+1i*0.2, 10-1i*0.2]; b=conj(a); c=b(ismember(b,a)); d=real(c)+1i*abs(imag(c)); e=unique...

5 years ago | 1

Answered
How to make a loop of a calculator that keeps asking until the input is zero/nothing?
You forgot to convert the result to a number, so it is a char array. %radian = input ('Input a number: ', 's'); %Input a numbe...

5 years ago | 1

| accepted

Answered
From for to While loop
Your original for-loop probably was incorrect. And why do you want a while loop? You already know how many iterations you want. ...

5 years ago | 0

| accepted

Answered
Possible combinations for a vector
s=[0,0,0,0,0,0,0,0,0]; max_value_of_s=2; num_combinations=(max_value_of_s+1)^numel(s); disp(num_combinations) That is going ...

5 years ago | 1

Answered
How do you circshift progressive rows an increasing amount?
You need to index a column in A in your output as well. for K = 1:size(A,2) A(:,K) = circshift(A(:,K),K); end If you want...

5 years ago | 0

| accepted

Answered
How do I overwrite a structure using a switch statement.
You can copy the code I used in my FEX submissions (see WBM, readfile, BlandAltmanPlot or RegGrow). If you simply want to ove...

5 years ago | 0

Answered
Keep getting an error as 'ASCII file unsupported' which terminates the code
The solution is in the error message: "Saving sparse arrays to an ASCII file is unsupported." Either use full to convert your s...

5 years ago | 0

| accepted

Answered
Selecting parts of HTML file
First read the html files (you can get my readfile function from the FEX. If you are using R2017a or later, you can also get it ...

5 years ago | 0

| accepted

Answered
How to eliminate standalone 1 or 0 in binary matrix
I would suggest using a convolution with a flat kernel. kernel=ones(1,3,1);kernel=kernel/sum(kernel(:)); A=[0 0 1 1 1 0 1 1 0 ...

5 years ago | 1

| accepted

Answered
how to extract a specific text/string from text file
You can either use my readfile function (which you can get from the file exchange or the add-on manager). Another option is to u...

5 years ago | 2

Answered
Count the number of times a sequence in a matrix repeats
Both the unique and ismember functions can handle rows. Look at the respective documentation pages for details.

5 years ago | 0

Answered
Split RGB Image into blocks (24-bit)
The better solution would be to use blockproc, but you can also use mat2cell and use a loop.

5 years ago | 0

Answered
How to perform circshift on specific elements?
You are overwriting the original array, instead of using circshift on the partial array. A = [1 2 3 4; 5 6 7 8; 9 10 11 12]; L...

5 years ago | 0

| accepted

Answered
displaying the total number of times an if statement is true
You can use the fact that sum will functionally cast your logical array to 0 and 1: grains=sum(xc_array(:,1)>0.188); fprintf('...

5 years ago | 0

| accepted

Answered
loop iteration in matlab
I would suggest not using a loop: F=@(x) sum( ( (1:x).^5 ).*(x:-1:1) );

5 years ago | 0

Answered
Removing white background from Barcode image(s)
The easiest solution is to not add the border in the first place: barWidth = 3;barHeight = 100;appendTerminationMarkers = false...

5 years ago | 1

| accepted

Answered
turn a vector into a scalar
I guess boldly: g=sym('0.1178542134') g_=double(g) %convert the scalar sym to a scalar double

5 years ago | 1

Answered
Thresholding a value in matrix
You can use the comparator operators to apply a threshold: data=randi(200,8,8); L= data<100; %L is true for all positions with...

5 years ago | 0

| accepted

Answered
How to colorize a range of pixel values in a grayscale image?
You can either adjust the colormap, or use imshow. If your image is not uint8, you will have to scale it down to [0,1] to make s...

5 years ago | 0

Answered
product selection for a mechanical engineer
If you have disk space to spare you can install all toolboxes that are available to you. Another strategy would be to only inst...

5 years ago | 2

Answered
How to remove file extension when using ugetfile in app designer?
The easiest way to remove an extension is with fileparts: [p,f,e]=fileparts(fullfilename); fullfilename=fullfile(p,f);

5 years ago | 2

| accepted

Answered
How to insert numbers into a empty vector in a loop
You should not put it in an empty vector. You should put the results in an array: [m,s]=ndgrid(1:5); xOut=zeros(size(m)); cou...

5 years ago | 1

Answered
Not enough input arguments for function length()
You are calling the a4_q3b function without input arguments. You did not give it any value for x, so when you try to use it, you...

5 years ago | 1

Answered
how to do sum of element of multiple number in matlab?
b=cumsum(m); b=b(c);

5 years ago | 3

| accepted

Answered
Delete patch in Matlab
Here is an example of what I wrote in my comment: t=linspace(0,2*pi,200); x=sin(t);y=cos(t); x=[x 0 0 2 2 -2 -2 0 0]; y=[...

5 years ago | 0

Answered
Copying all contents of a figure into another figure in Matlab GUIDE by clicking on a figure?
(Caveat: I haven't tried running any of this code) What are you expecting to happen when you set the ButtonDownFcn? It doesn't ...

5 years ago | 1

| accepted

Load more