988 total contributions since 2017

E-mails with feedback/questions about FEX submissions are welcomed. In general I will post e-mails about Answers on the related page, unless there is good cause not to do so.

Answered

How do I fix this

You are using t as an index to m_t, but that contains negative values. (in the call to trapz) I suspect you want to run the lin...

How do I fix this

You are using t as an index to m_t, but that contains negative values. (in the call to trapz) I suspect you want to run the lin...

16 hours ago | 0

| accepted

Answered

MATLAB Answers Wish-list #4 (and bug reports)

If a question is closed, you cannot write a comment anymore. E.g. this question was already closed, but since it was the first q...

MATLAB Answers Wish-list #4 (and bug reports)

If a question is closed, you cannot write a comment anymore. E.g. this question was already closed, but since it was the first q...

18 hours ago | 0

Answered

I have a code but it keep saying "invalid expression. when calling a function or indexing a variable, use parentheses. otherwise check for mismatched delimiters.

You are using square brackets for the sin function, instead of parentheses. Also, you were missing a lot of * signs. You should ...

I have a code but it keep saying "invalid expression. when calling a function or indexing a variable, use parentheses. otherwise check for mismatched delimiters.

You are using square brackets for the sin function, instead of parentheses. Also, you were missing a lot of * signs. You should ...

18 hours ago | 1

Answered

MATLAB Answers Wish-list #4 (and bug reports)

Since the new editor has become way more fancy: A while back I read in some help page for the Answers forum that a referrence t...

MATLAB Answers Wish-list #4 (and bug reports)

Since the new editor has become way more fancy: A while back I read in some help page for the Answers forum that a referrence t...

1 day ago | 2

Answered

Converting the program to the GUI version

There are many ways to share data between callbacks. In the context of GUIs the most often used function is guidata. You can al...

Converting the program to the GUI version

There are many ways to share data between callbacks. In the context of GUIs the most often used function is guidata. You can al...

1 day ago | 0

Answered

Hi there, I need to create a code that can replace the diagonal values on a matrix with 0's..

A=rand(5,5); A(size(A,2):(size(A,2)-1):(numel(A)-1))=0

Hi there, I need to create a code that can replace the diagonal values on a matrix with 0's..

A=rand(5,5); A(size(A,2):(size(A,2)-1):(numel(A)-1))=0

5 days ago | 1

Answered

Using xlsread in a for loop

If the worksheet names are 0.600 etc you can use the code below. B=struct; for n=20:-1:1 A= xlsread(filename,spri...

Using xlsread in a for loop

If the worksheet names are 0.600 etc you can use the code below. B=struct; for n=20:-1:1 A= xlsread(filename,spri...

7 days ago | 1

Answered

How to calculate 3D Positions using the distance from 3 separate points in space?

You could use something like the code below. It uses only base Matlab functions to search a position where the radii of your mea...

How to calculate 3D Positions using the distance from 3 separate points in space?

You could use something like the code below. It uses only base Matlab functions to search a position where the radii of your mea...

10 days ago | 0

| accepted

Answered

it says it has an untitled error in line 6 which i think it's about clause of if

You made the mistake of using |i| and |j| as variables and you forgot to initialize |j|. Also, think about what this code doe...

it says it has an untitled error in line 6 which i think it's about clause of if

You made the mistake of using |i| and |j| as variables and you forgot to initialize |j|. Also, think about what this code doe...

10 days ago | 0

| accepted

Answered

How can I calculate the area between two curves?

The |polyarea| function handles this just fine. figure(1),clf(1) x=0:1500; y1=@(x)(100./0.93).*(((x./19).^(10))./(1+(...

How can I calculate the area between two curves?

The |polyarea| function handles this just fine. figure(1),clf(1) x=0:1500; y1=@(x)(100./0.93).*(((x./19).^(10))./(1+(...

12 days ago | 0

| accepted

Answered

is it possible to write a code that experiments with zero mean Gaussian noise for a variance in the range 0.001 to 0.1

Yes, this is what for loops exist for. variance_list=.001:.001:0.01; for k=1:numel(variance_list) J = imnoise(MEANPIC...

is it possible to write a code that experiments with zero mean Gaussian noise for a variance in the range 0.001 to 0.1

Yes, this is what for loops exist for. variance_list=.001:.001:0.01; for k=1:numel(variance_list) J = imnoise(MEANPIC...

12 days ago | 0

| accepted

Answered

How to change elements in several arbitrary positions at the same time

You can use the |sub2ind| function (I used the |bsxfun| function to generate the row numbers) A=[0 0 0 0; 0 0 0 0; 0 0 0 0]...

How to change elements in several arbitrary positions at the same time

You can use the |sub2ind| function (I used the |bsxfun| function to generate the row numbers) A=[0 0 0 0; 0 0 0 0; 0 0 0 0]...

15 days ago | 0

Answered

MATLAB integer to roman numeral

I wouldn't hard-code the combinations, but use the rule instead. My proposal would look something like this: # convert the ch...

MATLAB integer to roman numeral

I wouldn't hard-code the combinations, but use the rule instead. My proposal would look something like this: # convert the ch...

16 days ago | 1

Answered

Assignment has more non-singleton rhs dimensions than non-singleton subscripts

|find| is not guaranteed to result 1 value. It might return a vector, or an empty array. If you are certain there will always be...

Assignment has more non-singleton rhs dimensions than non-singleton subscripts

|find| is not guaranteed to result 1 value. It might return a vector, or an empty array. If you are certain there will always be...

16 days ago | 0

Answered

Finding the index of a matrix corresponding to a particular column of another matrix

You can try this: A= [4 12 ; 2 6]; B = [9 4 8 12 ; 2 2 4 6]; selected_col=1; col_in_B=find(all(A(:,selected_col)==...

Finding the index of a matrix corresponding to a particular column of another matrix

You can try this: A= [4 12 ; 2 6]; B = [9 4 8 12 ; 2 2 4 6]; selected_col=1; col_in_B=find(all(A(:,selected_col)==...

17 days ago | 1

| accepted

Answered

Finding R squared in a loop

Just a quick note: a negative R-squared is actually possible. It just means your fit is so bad it is even worse than using the m...

Finding R squared in a loop

Just a quick note: a negative R-squared is actually possible. It just means your fit is so bad it is even worse than using the m...

17 days ago | 2

Answered

Keep prompting user instead of hitting run each time.

You can wrap your code in a while loop, but that will force the user to hard-break out of your code (ctrl-C on Windows). A nicer...

Keep prompting user instead of hitting run each time.

You can wrap your code in a while loop, but that will force the user to hard-break out of your code (ctrl-C on Windows). A nicer...

17 days ago | 0

Answered

How can I create 3D pixels image

The code generating the binary mask is relatively easy to extend, but you'll have to think about the image format you want to sa...

How can I create 3D pixels image

The code generating the binary mask is relatively easy to extend, but you'll have to think about the image format you want to sa...

21 days ago | 1

Answered

Gui appears and disappears before user can do anything with it

It is not because the figure is not visible yet, but because the GUI figure is not a callback figure at that point (at the most ...

Gui appears and disappears before user can do anything with it

It is not because the figure is not visible yet, but because the GUI figure is not a callback figure at that point (at the most ...

23 days ago | 0

| accepted

Answered

Calculate residuals as a single number in lsqnonlin function

Yes, the sum of squares or the RMS: SSq=sum(res.^2); RMS=sqrt(mean(res.^2)); The downside of using the plain sum is t...

Calculate residuals as a single number in lsqnonlin function

Yes, the sum of squares or the RMS: SSq=sum(res.^2); RMS=sqrt(mean(res.^2)); The downside of using the plain sum is t...

23 days ago | 1

Answered

Call OpeningFcn each time a button is pressed

There are two strategies I described: # Have a function that you call at the end of |OpeningFcn|. That function only call |ui...

Call OpeningFcn each time a button is pressed

There are two strategies I described: # Have a function that you call at the end of |OpeningFcn|. That function only call |ui...

24 days ago | 0

| accepted

Answered

i have used dwt2 function for my input image? for approximation level i am getting blank image. what sould i do ?

Your image is not white. |imshow| assumes your data is scaled from 0 to 1 if it is a double, while your data is clearly not from...

i have used dwt2 function for my input image? for approximation level i am getting blank image. what sould i do ?

Your image is not white. |imshow| assumes your data is scaled from 0 to 1 if it is a double, while your data is clearly not from...

24 days ago | 0

| accepted

Answered

Encryption scheme operands?

You forgot a space in your definition: Alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ '; numbers = [1,12,7,5,2;18,1,27,27,27]; ...

Encryption scheme operands?

You forgot a space in your definition: Alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ '; numbers = [1,12,7,5,2;18,1,27,27,27]; ...

24 days ago | 0

| accepted

Answered

nearest tangent point from Ginput point to line ?

My <https://www.mathworks.com/matlabcentral/fileexchange/64396-point-to-line-distance FEX submission> should help here. Unlike w...

nearest tangent point from Ginput point to line ?

My <https://www.mathworks.com/matlabcentral/fileexchange/64396-point-to-line-distance FEX submission> should help here. Unlike w...

25 days ago | 0

| accepted

Answered

How to modify this code for true result?

Your algorithm might not always result in an optimal packing. You should start with the biggest box and go down in volume. That ...

How to modify this code for true result?

Your algorithm might not always result in an optimal packing. You should start with the biggest box and go down in volume. That ...

26 days ago | 1

| accepted

Answered

Change matrix size for each successive experiment

Don't use |i| as a loop index, it may cause confusion/bugs and is trivial to avoid. m=1; for n = 101:100:2100 k =...

Change matrix size for each successive experiment

Don't use |i| as a loop index, it may cause confusion/bugs and is trivial to avoid. m=1; for n = 101:100:2100 k =...

26 days ago | 0

Answered

Help me Understand why my First Array Index is invalid

You also have a warning in the lint on this line. The mlint is a very useful tool in debugging, so you should make sure you have...

Help me Understand why my First Array Index is invalid

You also have a warning in the lint on this line. The mlint is a very useful tool in debugging, so you should make sure you have...

26 days ago | 0

Answered

XTicklabels don‘t match

If you want full control over the ticks, you must set both the ticks and their labels explicitly. If you don't, it may depend on...

XTicklabels don‘t match

If you want full control over the ticks, you must set both the ticks and their labels explicitly. If you don't, it may depend on...

26 days ago | 1

| accepted

Answered

final result depending on the consistency of ones and zeros

out0 = [1111000011110000] out1 = [1111111111111111] convert_to_1_bit=@(vector) mean(vector)>0.5; convert_to_1_bit...

final result depending on the consistency of ones and zeros

out0 = [1111000011110000] out1 = [1111111111111111] convert_to_1_bit=@(vector) mean(vector)>0.5; convert_to_1_bit...

27 days ago | 0

Answered

how to randomly delete number

Your code looks like you want to randomly fill one location with a one, but it has a bias toward the middle. The code below does...

how to randomly delete number

Your code looks like you want to randomly fill one location with a one, but it has a bias toward the middle. The code below does...

27 days ago | 0

| accepted