用MATLAB画柱状堆叠图,有负数怎么办呢?直接用bar(YY1,✀stack✀) 会相加抵消

2025-04-05 04:27:01
推荐回答(1个)
回答1:

function [years ] = populaction(filename)

%UNTITLED2 Summary of this function goes here

[num]=xlsread(filename);

x=num(1,:);

y=num(2,:);

subplot(1,3,1),plot(x,y,'b+:'),xlabel('x'),ylabel('ewew');

yy=interpl(x(~isnan(y)),y(~isnan(y)),x(isnan(y)));

index=find(isnan(y));

a=1;

while a<=length(find(isnan(y)))

    y(index(a))=yy(a)

    a=a+1;

end

subplot(1,2,3),plot(x,'-b*'),xlabel('deag'),ylabel('dsa')

coef=polyfit(x,y,2);

newy=polyval(coef,x);

subplot(1,3,3),plot(x,newy,'y'),xlabel('fdsf'),ylabel('tfg')

bbb={'years';'pop'};

number1=[x;y];

number2=num2cell(number1);

c=[bbb,number2]

xlswrite('book.xlsx',c)

years=1

end