Please help this semilogy error message

1 次查看(过去 30 天)
can you tell me what is wrong with this line ؟
it says
Error using semilogy
Not enough input arguments.
semilogy (BestCost(1,:),
'LineWidth',2,'Color','r',BestCost(2,:),'LineWidth',2,'Color','b')
figure;
semilogy (BestCost(1,:), 'LineWidth',2,'Color','r',BestCost(2,:),'LineWidth',2,'Color','b')
xlabel('Iteration');
ylabel('Best Cost');
legend('normal','stop and watch')
grid on;
hold on
thank you
  5 个评论
dpb
dpb 2023-5-15
编辑:dpb 2023-5-15
BestCost = [rand(1,10); rand(1,10)];
semilogy(BestCost.','linewidth',2)
xlabel('Iteration');
ylabel('Best Cost');
legend('normal','stop and watch')
grid on;
Don't need explicit x nor to plot each individually -- the one argument as a 2-column array uses the builtin interpretation by plot and friends to treat columns as separate variables; it rotates through the default colormap automagically, too.
Walter Roberson
Walter Roberson 2023-5-15
编辑:Walter Roberson 2023-5-15
semilogy (BestCost(1,:), 'LineWidth',2,'Color','r',BestCost(2,:),'LineWidth',2,'Color','b')
In the plotting functions, once you have start the first name/value pair, everything else on the line must be name/value pairs.
The plotting functions do not permit adding name/value pairs for each distinct set of data: the name/value pairs must go after all data specifications, and the name/value pairs will apply to all sets of data in the same call.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by