Plotting error bars on curve from .csv
Mostrar comentarios más antiguos
Hi! I am having difficulty plotting error bars in specific places along a curve created from a .csv. I didn't have luck pulling values from the .csv to try to create error bars, so I manually fille in the values I would need. The curve plots just fine without the errorbar section.
Can anyone help me place the errorbars at specific points on a curve? Thank you!
clear all
clc
data=csvread('average.csv');
x1=data(:,1);
y1=data(:,2);
x=[1,100,200,300,400,500,600,700,800,900,997]; %Where I want the error bars to lay on x axis
y=[100.0193,100.218,100.6957,97.98467,98.906,95.42566667,89.811,91.70433333,91.25666667,93.702,91.515]; %Where I want the error bars to lay on y axis
sd= [0.024,0.029,0.038,0.073,0.099,0.156,0.199,0.229,0.23,0.243,0.279,0.303]; %Standard deviation of the mean of three .csv data files
errorbar(x,y,sd)
plot (x1,y1,'Linewidth',1, 'color','b')
hold on
title('Average')
xlabel('Temperature [C]')
ylabel('Weight [%]')
Respuestas (1)
Star Strider
el 8 de Abr. de 2021
I am not certain what you want.
Try this:
x = [1,100,200,300,400,500,600,700,800,900,997];
y = [100.0193,100.218,100.6957,97.98467,98.906,95.42566667,89.811,91.70433333,91.25666667,93.702,91.515];
sd = [0.024,0.029,0.038,0.073,0.099,0.156,0.199,0.229,0.23,0.243,0.279,0.303];
sd = sd(1:numel(x));
x1 = linspace(0, 1000, 50); % Create Vector
y1 = max(y)+sin(2*pi*x1/250)*(max(y)-min(y)) + randn(size(x1))*0.2; % Create Vector
figure
plot(x1, y1)
hold on
errorbar(x, y, sd, '.', 'MarkerSize',0.25)
hold off
grid
Use your own values for ‘x1’ and ‘y1’.
Categorías
Más información sobre Errorbars en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!