Plot graph with different variables in loop
古いコメントを表示
Hi, I am very new to matlab, i am trying my best to run a program for differnet set of values. For example i have X and multiple Y and i am trying to run my code for diffenrent set of Y. For example, for first i need the graph with X and (Y1,Y2 and Y3) and then for the next, i need the graph for X and (Y4, Y5 AND Y6). i am trying to loop the fukction but i can not get any output, i am jsut getting erroe. Any help would be appriciated, how to run the loop. i am posting my written code for the same.
%input parameters for ICAR
%inner radius
r1=.063
%outer radius
r2=.143
%height of vane
h=.127
%shear strain
x=[.05 .125 .2 .275 .350 .425 .5];
%%Control concrete
% Mix 1-0
y1=[0.19999 0.27373 0.35502 0.46733 0.56426 0.6148 0.77323];
%Mix 1-15
y2=[0.36145 0.53114 0.61001 0.83706 0.90438 1.01193 1.29474];
%Mix 1-30
y3=[0.76393 0.76999 0.90382 1.13418 1.33516 1.46713 1.70122];
hold on
scatter (x,y1);
scatter (x,y2);
scatter (x,y3);
grid on
%xlim([0.5 4.5])
title('Curve data from ICAR rheometer')
%% Fit: 'Bingham fit'.
[xData1, yData1] = prepareCurveData( x, y1 );
[xData2, yData2] = prepareCurveData( x, y2 );
[xData3, yData3] = prepareCurveData( x, y3 );
% Set up fittype and options.
ft = fittype( 'H*x+G', 'independent', 'x', 'dependent', 'y' );
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';
opts.StartPoint = [0.349658020198746 0.632520311675498];
% Fit model to data.
[fitresult1, gof] = fit( xData1, yData1, ft, opts );
[fitresult2, gof] = fit( xData2, yData2, ft, opts );
[fitresult3, gof] = fit( xData3, yData3, ft, opts );
hold on
figure
title('Bingham parameters G, H')
hold on
h1 = plot( fitresult1,'k', xData1, yData1,'xk' );
h2 = plot( fitresult2,'r', xData2, yData2,'*r' );
h3 = plot( fitresult3,'b', xData3, yData3,'+b' );
hold off
% Label axes
legend('0 mins','','15 mins','','30 mins','','location','nw')
xlabel ('Rotaional speed (rps)')
ylabel ('Torque (Nm)')
xlim([0 0.6])
ylim([0 1.6])
grid on
now iamgine i ahve more data of Y i want to repeat this whole thing with those daya as i dont want to copy paste and edit each and every thing.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Surface and Mesh Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!