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 个评论
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.
Can you attach your data so we can test?
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
attached,
also error bar loaded from A data. as well which is the 3rd column.
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()
scatter
I want to know the right code for get the values of error bar from excel and plot it.
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);
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.
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.
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.
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.
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 的更多信息
标签
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 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)
