How do I output to the command window where the sum of the bars on the graph equal zero along the x axis

1 回表示 (過去 30 日間)
clc;
clear;
close all;
A= -15000;
A(2:6)= 3200;
A(7:9)= [2133.333, 1066.667, 1000];
n=length(A);
for i =1:n
x(i) = i-1;
end
bar(x,A,0.25)
PW= 0;
int=[1.06 1.08 1.1];
for j= 1:length(int)
PW=0;
for t= 1:n
PW=PW+A(t)*int(j)^(-x(t));
PWA(j,t)=PW;
end
end
figure(1)
hold on
plot(x,PWA,'-x','LineWidth',2)
legend('CF diagram','1.06','1.08','1.1','Location','southeast')

回答 (1 件)

Star Strider
Star Strider 2019 年 4 月 23 日
If fyou are referring to ‘PWA’, try this (after your plot call):
for k = 1:size(PWA,1)
PWA0(k) = interp1(PWA(k,:), x, 0, 'linear', 'extrap');
fprintf('PWA = 0 at x = %4.2f\n', PWA0(k))
end
When I ran it, the result was:
PWA = 0 at x = 6.02
PWA = 0 at x = 7.47
PWA = 0 at x = 9.40
Experiment to get the result you want.

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by