Could anyone help me to solve the issue in the following code
Show older comments
I have run the following code:
one.m in one script
r = 2
c = 10
[x,v] = randfixedsum(r*c,1,0.35,0.01,0.09)
y = reshape(x,r,c)
sum(y(:))
------------------
In another script
function x = myfunction()
r = 2
c = 10
x = my_randfixedsum(r,c)
end
--------------------------------
In another script
function y = my_randfixedsum(r,c)
a = 0.01
b = 0.09
s = 0.35
n = r * c
m = 1
if n * a > s || n * b < s
error('Cannot create a sum of %f by adding together %d x %d numbers in the range %f to %f', s, r, c, a, b);
end
randomvec = randfixedsum(n, m, s, a, b)
y = reshape(randomvec, r, c)
end
when i run the code it works. but when i change the value of r=4 it results in Error using randfixedsum (line 46) Inequalities n*a <= s <= n*b and a < b must hold.
Error in one (line 6) [x,v] = randfixedsum(r*c,1,0.35,0.01,0.09). could you please help me on it. Could anyone help me to fix it.
2 Comments
@Prabha Kumaresan: why did you copy the code and help I gave in my answer ... yet accepted a different (useless) answer and did not even give a single word of thanks for me helping you?:
Do you imagine that it is okay to take my knowledge andefforts and use it without thanking or acknowledging my (volunteered) time helping you? Taking someone's idea without acknowledgement is called plagiarism.
@Stephen: Prabha has a hard time to use Matlab and this forum. Of course it would be better, if Prabha cares about the customs in the forum e.g. by posting 1 thread per problem, answering questions for clarifications and carefully accepting the answer, which solves the problem. But as long as this is not the case, I'm sure it is the best not to take it personally.
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!