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

조회 수: 2 (최근 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 CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by