Info

This question is closed. Reopen it to edit or answer.

How do i modify the code when a=0,a=0.1,...,a=0.9,a=1

1 view (last 30 days)
yang-En Hsiao
yang-En Hsiao on 2 Oct 2019
Closed: yang-En Hsiao on 2 Oct 2019
I want to calculate the Ps when a=0.1,a=0.2,....,a=0.9,a=1.0 , so i think i should have 11 different Ps number,however,the window always show me 11 same number,it seems that it just calculate 11 times when the "a" is the same number.
How do i modify my code?
a=0:0.1:1
B=[1;2;3;4;5;6]
C=[7;8;9;10;11;12]
gN=1;
for i=1:1:length(a)
f_A=( a(i)*B+(1-a(i))*C)/norm( (a(i)*B+(1-a(i))*C) );
PsB=abs((gN)/(f_A'*f_A));
PsC=abs((gN)/(f_A'*f_A));
if PsB > PsC
Ps(i)=PsB
else
Ps(i)=PsC
end
end
The window show me
Ps =
Columns 1 through 5
1.0000 1.0000 1.0000 1.0000 1.0000
Columns 6 through 10
1.0000 1.0000 1.0000 1.0000 1.0000
Column 11
1.0000
  1 Comment
Ankit
Ankit on 2 Oct 2019
it should be the same number
PsB = num/den , your num is 1 and product of f_A'*f_A is also 1.
What i dont understand size of your variable a is 11, B & C is 6.

Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!