"The function 'x' might be used before it is defined " error is coming. can anyone help?
1 view (last 30 days)
Show older comments
function [P1,P2,P3]=assignment1(PD)
a=(x-8)/.04;
b=(x-10)/.08;
c=(x-6)/.16;
while (a<=500) && (a>=150) && (b<=400) && (b>=100) && (c<=200) && (c>=50) && ((a+b+c)==PD)
for x=0:0.1:50
P1=(x-8)/.04;
P2=(x-10)/.08;
P3=(x-6)/.16;
end
end
0 Comments
Answers (1)
Walter Roberson
on 19 Sep 2018
You probably want a structure more like
counter = 0;
for x = ...
a = ...
b = ...
c = ...
if (a<=500) && (a>=150) && (b<=400) && (b>=100) && (c<=200) && (c>=50) && ((a+b+c)==PD)
counter = counter + 1;
P1(counter) =(x-8)/.04;
P2(counter) =(x-10)/.08;
P3(counter) =(x-6)/.16;
end
end
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!