Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
Hello,
In the attached worksheet, inside the function "pulse2", the function L(k, θ, re ,d ,ti ) must be summed over different values of θ. Could you please help me to resolve the error message?
All the best,
Payman
Solved! Go to Solution.
If origin = 0, you can not start qq from -2. Then you should change the loop start, in qq + 2
Thank you, but I'm not quite sure what you mean.
Just to make it clear, whatever theta would be later, I want to add the values of "L" from two cells before to two cells after that.
I would like to point out that if there is beta in the list of parameters of the function pulse2(...), instead of beta110, we have:
"Just to make it clear, whatever theta would be later, I want to add the values of "L" from two cells before to two cells after that."
Then you must make sure that Theta is a vector, and it can have indexes running as low as -2. With and ORIGIN setting of 0 that is not possible.
In your program you have a for loop where qq runs from -2 to 2 (in steps of 1).
when it comes to assigning p1 you use qq as the range for a summation. You must realise that what actually occurs is that p1i,1, which is the element of matrix p1 in the i-th row and second column (due to ORIGIN=1) gets assigned a new value five times over (qq runs from -2 to 2).
But it fails at the first attempt, because the summation operator that you used expects qq to be a range. It isn't, it's a value: -2. At the next attempt (well, it doesn't get there, due to the error in the first attempt) it would be again a value: -1 and so forth until qq = +2.
I guess you want to first calculate the sum, then assign it to p1i,1.
The better way to do that is to omit the for-loop assignment and use the summation operator with upper and lower bounds:
Similar for p2.
Now there's another problem, the one that FM was pointing at. Your array theta needs to be an array. You are calling the pulse function with argument beta110, which is an array element at best, not an array, and not with an index below 0 (=ORIGIN).
Success!
Luc
Thank you, I see what you mean. I'm going to change the structure of the function.
Could you please help me with the error message?
The output of the function “pulse2” is the times that the signal received by the left and the right microphones just reaches the threshold value.
But sometimes (as is shown in the worksheet) the signal never reaches the threshold value and hence there is no output . How can I setup the program that in this situation returns (0,0) value so the rest of my program continue working.
Thank you very much
Payman
At first glance, since everything depends on the threshold, I made this change where there is a comparison with the threshold. Could it be OK?
Then it always returns (0,0) even when the signal reaches the threshold value.
Here is my complete program. The error also affect the next function.
See Werner what he recommends. today I am not in the mood to program.
Thank you for your suggestions.
Just initialize m1 and m2 as a 1x1 matrix containing a zero.
BTW, it would be better style to initialize j and jj to zero at the top of the program.
Here are two streamlined versions of your pulse2 program. There is no need to create that many (unused) arrays.
The last one running a little bit faster.
If in the case of one of the values being zero you really want to see (0 0) this would be easy to accomplish
Thank you very much Werner, you are great.
I'm sorry, I am still in trouble with the rest of my program. Would you please take a look.
Thanks a lot.