Errorbars on a select dataset

1 回表示 (過去 30 日間)
Jocelyn Kenley
Jocelyn Kenley 2022 年 6 月 3 日
回答済み: Star Strider 2022 年 6 月 3 日
I am trying to make an errorbar on a certain dataset. Here the code I have now:
M=mean(f);
x=g;
y=f;
errorbar(g,f,err);
plot(data2(:,2),data2(:,3:5))
xlim([0 50000])
ylim([0 100])
But i keep getting an error on line 4.

回答 (2 件)

Michael Van de Graaff
Michael Van de Graaff 2022 年 6 月 3 日
編集済み: Michael Van de Graaff 2022 年 6 月 3 日
You haven't defined err, f, or g.
Also, please post the FULL error message for better help
this produces an errorbar plot:
x = 1:10;
y = sqrt(x);
yerr = rand(size(y));
errorbar(x,y,yerr)

Star Strider
Star Strider 2022 年 6 月 3 日
Try this —
data2 = sortrows(randn(10,5),2); % Correct For Missing Data
Experimental = sortrows(randn(10,5),2); % Correct For Missing Data
g=Experimental(:,2);
f=Experimental(:,3:5);
M=mean(f); % This Won't Work - It Takes The 'mean' Of The Columns And You Want The Mear Of The Rows
x=g;
y=mean(f,2); % This WILL Work (Rows 'mean')
err = std(f,[],2); % Correct For Missing 'err' Assignment
figure
errorbar(x,y,err);
hold on % Use The 'hold' Functiono To Plot More Than One Series On An 'axes' Ofject
plot(data2(:,2),data2(:,3:5))
hold off
% xlim([0 50000]) % Use With Actual Data
% ylim([0 100]) % Use With Actual Data
Please visit MATLAB Academy.
.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by