How to display non-zero part of a curve

Hi ,i have a function that I want to solve algorithm with taboo, I declared this function as follows:
function F=soleval(SB,SGM,eNodeB,c,h)
F=[0];
tabUnik = unique(SB);
tabaffes=bsxfun(@eq,tabUnik(:),SB);
tabaffee=bsxfun(@eq,SB(:),SB);
x=bsxfun(@eq,tabaffes,1);
z=bsxfun(@eq,1,tabaffee);
for k=1:SGM;
for e1=1:eNodeB;
for e2=1:eNodeB;
e1~=e2;
y(e1,e2)=z(e1,e2);
f=(c(k,e1))*x(k,e1)+(h(e1,e2))*(1-y(e1,e2));
F=[F;f];
end
end
end
in the main program and after passing through different instructions taboo algorithm I show the variation of this function using the plot function:
F=soleval(SB,SGM,eNodeB);
plot(F);
my problem is that I just want to display the non-zero part of the function. Thank you for helping me.

 採用された回答

Matt Fig
Matt Fig 2012 年 9 月 10 日
編集済み: Matt Fig 2012 年 9 月 10 日

1 投票

I assume when you say that you want to "display the non-zero values" you mean you want to "plot only the non-zero values."
G = F; % Save F for other use
G(~G) = nan; % nan values are not shown in a plot.
plot(G)

5 件のコメント

ISIMG
ISIMG 2012 年 9 月 10 日
thank you very much but i want that this elimination doses not appears,in other words , i want the curve to be complete and and that there is no space between points.
Matt Fig
Matt Fig 2012 年 9 月 10 日
編集済み: Matt Fig 2012 年 9 月 10 日
What kind of interpolation would you like to have connecting points on either side of the zeros? And what to do if that interpolation results in another zero?
You see, in order to not have a blank space in the plot, we have to have some non-nan value. If that value is zero but you don't want to show zeros, then you have to put some other value. So, what value do you want to take the place of the zeros??
ISIMG
ISIMG 2012 年 9 月 10 日
if i want to put 9 ?
Matt Fig
Matt Fig 2012 年 9 月 10 日
Do like I did above, but replace nan with 9.
ISIMG
ISIMG 2012 年 9 月 10 日
thank you very much it's working

サインインしてコメントする。

その他の回答 (0 件)

質問済み:

2012 年 9 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by