error bar from xlsx
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
Hello
I have data from excel and I imported and everything going fine except error bar doesn't work
I have an error bar in column 3, this is the first time I use it.
Thank you in advance.
A=importdata('value.xlsx')
x=A.data(:,2)
b=A.data(:,1)
err=A.date(:,3)
S1=plot(x,b,err,'sk','MarkerFaceColor','k')
error(x,b,err)
採用された回答
Walter Roberson
2019 年 10 月 7 日
The function to plot error bars is errorbar() not error()
13 件のコメント
Abdullah Al Alhareth
2019 年 10 月 7 日
A=importdata('value.xlsx')
x=A.data(:,2)
b=A.data(:,1)
err=A.date(:,3)
S1=plot(x,b,err,'sk','MarkerFaceColor','k')
errorbar(x,b,err)
still doesnt work.
Walter Roberson
2019 年 10 月 7 日
Can you attach your data so we can test?
Walter Roberson
2019 年 10 月 7 日
Is it correct that you want to load err from a different variable ? x and b are loaded from A.data but err is loaded from A.date -- data compared to date
Abdullah Al Alhareth
2019 年 10 月 7 日
attached,
also error bar loaded from A data. as well which is the 3rd column.
Walter Roberson
2019 年 10 月 7 日
What are you expecting when you use plot() to plot three variables? Are you expecting a 3D scatter plot? If so then use plot3() or scatter3()
Abdullah Al Alhareth
2019 年 10 月 7 日
scatter
I want to know the right code for get the values of error bar from excel and plot it.
Walter Roberson
2019 年 10 月 7 日
data = readtable('value.xlsx', 'ReadVariableNames',false);
x = data{:,1};
b = data{:,2};
err = data{:,3};
[sx, idx] = sort(x);
sb = b(idx);
serr = err(idx);
plot(sx, sb, 'sk', 'MarkerFaceColor','k');
errobar(sx, sb, serr);
Abdullah Al Alhareth
2019 年 10 月 7 日
basically I plot x and y from data A which is columns 1 and 2.
Now my error bar in column 3 and I want to use it as an error bar.
Walter Roberson
2019 年 10 月 7 日
That is what the code I posted does. It takes time to sort the data because your x was not in order, which was leading to lines doubling back on themselves.
Abdullah Al Alhareth
2019 年 10 月 7 日
編集済み: Walter Roberson
2019 年 10 月 7 日
Ok , forget about the excel file I uploaded , let’s just do it in the original code which it import data from excel, my error bar is column 3. Which code will be working with it ?
A=importdata('value.xlsx') x=A.data(:,2) b=A.data(:,1) errorbar=A.date(:,3) S1=plot(x,b,errorbar,'sk','MarkerFaceColor','k').
I Tried this one and doesn’t work. keep it as importdata. I want to learn the right code so I can use it for another xlsx files.
Thank you in Advance.
Walter Roberson
2019 年 10 月 7 日
readtable() is the right code. importdata() is older and fragile, returning different data types depending on whether it finds headers in the file or not.
But if you insist:
filename = 'value.xlsx';
A = importdata('value.xlsx');
x = A.data(:,2);
b = A.data(:,1);
err = A.data(:,3);
[sx, idx] = sort(x);
sb = b(idx);
serr = err(idx);
plot(sx, sb, 'sk', 'MarkerFaceColor', 'k')
errorbar(sx, sb, serr)
The sort() step will not hurt if the data is already sorted, and will help if the data is in the wrong order.
Abdullah Al Alhareth
2019 年 10 月 7 日
Actually the excel I uploaded it's not the right one, but the data I have all three column It should be in same order, for example if I sorted x then the data will be missed up. That's why.
Walter Roberson
2019 年 10 月 7 日
filename = 'value.xlsx';
A = importdata('value.xlsx');
x = A.data(:,2);
b = A.data(:,1);
err = A.data(:,3);
plot(x, b, 'sk', 'MarkerFaceColor', 'k')
errorbar(x, b, err)
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Errorbars についてさらに検索
タグ
参考
2019 年 10 月 7 日
2019 年 10 月 7 日
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
