1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721
|
clc;clear close all
color1=[147 213 220]/255; color2=[242 202 201]/255; color3=[198 223 200]/255;
FontSize=13; color3s={color1;color2;color3}; colors={color1;color1;color1;color2;color2;color2;color3;color3;color3}; colors9=[ 199 92 100 240 181 125 211 225 174 113 171 182 75 90 161 76 139 192 232 49 51 163 96 173 94 183 91]/255;
ki=[ 1 0 0 0.75 0.25 0 0.5 0.5 0 0.25 0.75 0 0 1 0 0 0.75 0.25 0 0.5 0.5 0 0.25 0.75 0 0 1]; bar_colors=ki*[color1;color3;color2];
legends=["v=240mm/s T=210°C h=0.16mm" "v=250mm/s T=215°C h=0.20mm" "v=260mm/s T=220°C h=0.24mm" "v=240mm/s T=215°C h=0.24mm" "v=250mm/s T=220°C h=0.16mm" "v=260mm/s T=210°C h=0.20mm" "v=240mm/s T=220°C h=0.20mm" "v=250mm/s T=210°C h=0.24mm" "v=260mm/s T=215°C h=0.16mm"]'; legends9=[legends;repmat("",5,9)];
hexc=[ '32aeec' 'E3863c' 'E9262e'];
r=hex2dec(hexc(:,[1,2])); g=hex2dec(hexc(:,[3 4])); b=hex2dec(hexc(:,[5 6])); rgb=[r,g,b];
Tensile_x=cell(9,6); Tensile_y=cell(9,6);
opts = delimitedTextImportOptions("NumVariables", 8);
opts.DataLines = [8, Inf]; opts.Delimiter = "\t";
opts.VariableNames = ["Load", "LoadY", "Position", "Displacement", "Extension", "ExtensionY", "StepIndex", "Time"]; opts.VariableTypes = ["double", "double", "double", "double", "double", "double", "double", "double"];
opts.ExtraColumnsRule = "ignore"; opts.EmptyLineRule = "read"; T_L0=50; T_S0=4*13; for Gi=1:9 for ti=1:6 filesname=sprintf("/Users/mawenqian/Documents/硕士/VSL/科研/小论文1/基本试件打印参数正交试验/G%d/N%d.txt",Gi,ti); readdata = readtable(filesname, opts); readdata = table2array(readdata); Tensile_x{Gi,ti}=readdata(:,5)/T_L0*100; Tensile_y{Gi,ti}=readdata(:,1)/T_S0; clear readdata filesname end end clear opts save Tensile_raw_data Tensile_x Tensile_y
Tensile_start_line=[ 133 137 137 144 145 139 151 151 147 157 160 155 176 178 177 179 191 174 168 205 143 194 162 192 157 162 163 154 222 170 196 242 175 206 246 174 143 141 145 130 138 146 133 129 135 126 130 127 145 150 163 145 138 142]; Tensile_end_line=[ 2022 1764 3568 2073 2596 3338 2222 1912 2363 3740 1927 1832 2613 1821 2390 2353 2041 2040 4000 3000 2449 2667 2557 1937 2000 1943 2000 1776 2000 2000 1719 1719 1719 1719 1719 1719 2312 1975 2537 2161 1730 1979 1407 1238 1345 1260 1593 1684 1656 2419 2000 2000 2000 2000]; Tensile_maxy_line=[ 740 709 744 730 755 716 1066 1103 1064 1167 1058 1157 834 709 735 779 779 723 1377 1441 1622 1512 1698 1399 1043 1074 1069 1140 1072 1036 1214 1142 1164 1214 1142 1164 1178 1099 1213 1252 1191 1182 1097 1091 1081 1035 1100 1063 853 903 920 896 891 922];
Tensile_maxy=zeros(9,6);
clear fh1 fh1=figure(); set(gcf,'unit','centimeters','Position',[15 15 15 15]); axes('parent',fh1,'unit','centimeters','position',[1.5 1.5 12.5 12.5]); hold on LineStyles=repmat(["-",":","--"],1,3); for Gi=1:9 for ti=1:6 x=Tensile_x{Gi,ti}(Tensile_start_line(Gi,ti):Tensile_end_line(Gi,ti));x=x-x(1); y=Tensile_y{Gi,ti}(Tensile_start_line(Gi,ti):Tensile_end_line(Gi,ti));y=y-y(1); Tensile_maxy(Gi,ti)=max(y); plot(x,y,LineWidth=1.5,Color=colors{Gi},LineStyle=LineStyles(Gi)) clear x y end xlabel("Strain (%)") ylabel("Stress (MPa)") xlim([0 8]) ylim([0,60]) legend(legends9,Location="northeast",Box="off"); box('on'); set(gca,'FontName','Arial','FontSize',FontSize) end
compressive1_x=cell(9,6); compressive1_y=cell(9,6); Com1_L0=25.4; Com1_S0=12.7*12.7*pi*0.25;
opts = spreadsheetImportOptions("NumVariables", 2);
opts.Sheet = "Sheet1"; opts.DataRange = "A2:B2000";
opts.VariableNames = ["LoadValue", "PositionValue", "PlayTime", "ExtendValue"]; opts.VariableTypes = ["double", "double", "double", "double"]; for Gi=19:27 for ti=1:6 filesname=sprintf("/Users/mawenqian/Documents/硕士/VSL/科研/小论文1/基本试件打印参数正交试验/G%d/N%d.xls",Gi,ti); readdata = readtable(filesname, opts); readdata = table2array(readdata); compressive1_x{Gi-18,ti}=readdata(:,2)/Com1_L0*100; compressive1_y{Gi-18,ti}=readdata(:,1)/Com1_S0; clear readdata filesname end end clear opts
compressive1_start_line=[ 73 78 74 77 12 1 77 87 79 78 75 77 82 82 80 82 86 83 369 70 64 72 72 74 71 67 66 63 64 66 70 70 68 67 69 69 62 6 6 5 4 4 3 3 3 181 1 7 65 12 5 4 5 64]; compressive1_end_line=[ 471 413 432 390 303 322 422 432 413 380 380 378 471 442 480 390 303 322 827 529 493 497 503 482 511 526 453 475 496 496 513 509 528 486 473 494 528 516 475 414 463 470 463 454 519 605 463 457 619 497 496 365 420 478]; compressive1_maxy_line=[310 307 318 314 234 219 354 377 344 374 352 345 321 325 333 324 303 322 728 412 381 403 404 404 357 350 340 344 345 347 349 330 332 341 329 339 331 295 293 279 286 314 306 285 300 499 313 293 436 274 300 289 298 323];
compressive1_maxy=zeros(9,6);
clear fh1 fh1=figure(); set(gcf,'unit','centimeters','Position',[15 15 15 15]); axes('parent',fh1,'unit','centimeters','position',[1.5 1.5 12.5 12.5]); hold on LineStyles=repmat(["-",":","--"],1,3); for Gi=19:27 Gi=Gi-18; hold on for ti=1:6 x=compressive1_x{Gi,ti}(compressive1_start_line(Gi,ti):compressive1_end_line(Gi,ti));x=x-x(1); y=compressive1_y{Gi,ti}(compressive1_start_line(Gi,ti):compressive1_end_line(Gi,ti));y=y-y(1); compressive1_maxy(Gi,ti)=max(y); plot(x,y,LineWidth=1.5,Color=colors{Gi},LineStyle=LineStyles(Gi)) end xlabel("Strain (%)") ylabel("Stress (MPa)") xlim([0 8]) ylim([0,60]) legend(legends9,Location="southeast",Box="off"); box('on');
set(gca,'FontName','Arial','FontSize',FontSize) end
Flexural_x=cell(9,6); Flexural_y=cell(9,6);
opts = delimitedTextImportOptions("NumVariables", 8);
opts.DataLines = [8, Inf]; opts.Delimiter = "\t";
opts.VariableNames = ["Load", "LoadY", "Position", "Displacement", "Extension", "ExtensionY", "StepIndex", "Time"]; opts.VariableTypes = ["double", "double", "double", "double", "double", "double", "double", "double"];
opts.ExtraColumnsRule = "ignore"; opts.EmptyLineRule = "read"; L0=6*3.2/52^2; S0=3*52/(2*12.7*3.2^2); for Gi=10:18 for ti=1:6 filesname=sprintf("/Users/mawenqian/Documents/硕士/VSL/科研/小论文1/基本试件打印参数正交试验/G%d/N%d.txt",Gi,ti); readdata = readtable(filesname, opts); readdata = table2array(readdata); Flexural_x{Gi-9,ti}=readdata(:,4).*L0*100; Flexural_y{Gi-9,ti}=readdata(:,1).*S0; clear readdata filesname end end clear opts
Flexural_start_line=[ 467 518 522 779 368 484 519 337 270 390 415 252 517 357 717 515 553 654 770 553 453 344 498 318 498 521 569 667 510 417 360 431 407 364 472 358 308 493 677 617 648 471 379 529 641 781 915 439 693 701 745 696 734 744]; Flexural_maxy_line=[ 4554 4543 4534 4729 4459 4457 4391 4252 4080 4298 4264 4114 4496 4306 4691 4533 4453 4458 4431 4205 4134 3991 4242 4116 4529 4633 4710 4794 4624 4509 4078 4153 4095 4148 4172 4140 4059 4267 4356 4334 4289 4146 4165 4235 4366 4562 4611 4207 4725 4725 4725 4725 4725 4725];
Flexural_maxy=zeros(9,6);
clear fh1 fh1=figure(); set(gcf,'unit','centimeters','Position',[15 15 15 15]); axes('parent',fh1,'unit','centimeters','position',[1.5 1.5 12.5 12.5]); hold on LineStyles=repmat(["-",":","--"],1,3); for Gi=10:18 Gi=Gi-9;
hold on for ti=1:6 x=Flexural_x{Gi,ti}(Flexural_start_line(Gi,ti):end);x=x-x(1); y=Flexural_y{Gi,ti}(Flexural_start_line(Gi,ti):end);y=y-y(1); Flexural_maxy(Gi,ti)=max(y); plot(x,y,LineWidth=1.5,Color=colors{Gi},LineStyle=LineStyles(Gi)) end
end
xlabel("Strain (%)") ylabel("Stress (MPa)") xlim([0 8]) ylim([0,70])
legend(legends9,Location="southeast",Box="off"); box('on');
set(gca,'FontName','Arial','FontSize',FontSize)
com_bar=figure(); set(gcf,'unit','centimeters','Position',[5 5 28 28]); axes('parent',com_bar,'unit','centimeters','position',[1.5 1.5 25 25],'fontsize',20);
x=1:9; all_mean=reshape(mean([Tensile_maxy;compressive1_maxy;Flexural_maxy],2),9,3)'; all_mean_std=reshape(std([Tensile_maxy;compressive1_maxy;Flexural_maxy],0,2),9,3)';
bar_fig= bar(x,all_mean,FaceColor="flat",BarWidth=0.8); hold on
for typei=1:3
set(bar_fig(typei),'FaceColor',color3s{typei});
errorbar(x+0.225*(typei-2),all_mean(typei,:),all_mean_std(typei,:),'LineStyle','none',LineWidth=1.5,Color=[0.5 0.5 0.5]);
xtips = bar_fig(typei).XEndPoints; ytips = bar_fig(typei).YEndPoints+all_mean_std(typei,:); label = string(vpa(bar_fig(typei).YData,3)); text(xtips,ytips,label,'HorizontalAlignment','center','VerticalAlignment','bottom','FontSize',12) end legend(["Tensile Yield Strength" "Compressive Yield Strength" "Flexural Yield Strength" ],Location="northwest",box="on")
ylabel("Stress (MPa)") set(gca,'FontName','Arial','FontSize',14)
figure(); ti=1; set(gcf,'unit','centimeters','Position',[3 3 15 15]); axes('unit','centimeters','position',[1.5 1.5 12.5 12.5]); bar_fig_i= bar(x,all_mean(ti,:),BarWidth=0.8,FaceColor=color2); hold on errorbar(x,all_mean(ti,:),all_mean_std(ti,:),'LineStyle','none',LineWidth=1.5,Color=[0.5 0.5 0.5]);
xtips = bar_fig_i.XEndPoints; ytips = bar_fig_i.YEndPoints+all_mean_std(ti,:); label = string(vpa(bar_fig_i.YData,3)); text(xtips,ytips,label,'HorizontalAlignment','center','VerticalAlignment','bottom')
ylabel("Stress (MPa)") set(gca,'FontName','Arial','FontSize',FontSize)
all_sigma=[Tensile_maxy(:),compressive1_maxy(:),Flexural_maxy(:)];
save sigma_mat all_sigma all_mean all_mean_std Tensile_maxy compressive1_maxy Flexural_maxy
load('sigma_mat.mat') A=repmat([1 1 1 2 2 2 3 3 3]',6,1); B=repmat([1 2 3 1 2 3 1 2 3]',6,1); C=repmat([1 2 3 2 3 1 3 1 2]',6,1); D=repmat([1 2 3 3 1 2 2 3 1]',6,1); save taguchi9_mat A B C D
sn=-10*log10(1./all_sigma.^2); anova_soure_tbl= [{'A','B','C','D','Tensile','Compressive','Flexural'};[num2cell([A B C D]), num2cell(sn)]]; all_anova=cell(3,1); for ni=1:3 [~,tbli]=anovan(sn(:,ni),{A,B,C,D},"varnames",{'A','B','C','D'}); tbli{1,1}='Factor'; percent_source=cell2mat(tbli(2:6,5)); percent=[{'Contribution'};num2cell(round(100*[percent_source;sum(percent_source)]./sum(percent_source),2))];
all_anova{ni}=[tbli(:,[1 2 3 5 6 7]),percent];
end save anovan_mat all_anova anova_soure_tbl
all_sigma2square=1./all_sigma.^2; all_sn=cell(3,1);
for ni=1:3 [tbl_A,grp_A]=grpstats(all_sigma2square(:,ni),A,["mean","gname"]); [tbl_B,grp_B]=grpstats(all_sigma2square(:,ni),B,["mean","gname"]); [tbl_C,grp_C]=grpstats(all_sigma2square(:,ni),C,["mean","gname"]); [tbl_D,grp_D]=grpstats(all_sigma2square(:,ni),D,["mean","gname"]);
sni=-10*log10([tbl_A,tbl_B,tbl_C,tbl_D]); sni_delta=max(sni)-min(sni); [~,sni_sort]=sort(sni_delta,'descend'); [~,sni_sort]=sort(sni_sort); all_sn{ni}=cell(size(sni)+[3 1]); all_sn{ni}(1,:)={'Level' 'A','B','C','D'}; all_sn{ni}(2:end,1)={'1' '2' '3' 'Delta' 'Rank'}; all_sn{ni}(2:end,2:end)=[num2cell([sni;sni_delta]);num2cell(sni_sort)];
end save all_sn_mat all_sn
close all which_sigma=1; y1=cell2mat(all_sn{which_sigma}(2:4,2)); y2=cell2mat(all_sn{which_sigma}(2:4,3)); y3=cell2mat(all_sn{which_sigma}(2:4,4)); y4=cell2mat(all_sn{which_sigma}(2:4,5));
plot([y1;y2;y3;y4]) ylim_range=[18 32];
FontSize=13; fh1=figure(); set(gcf,'unit','centimeters','Position',[2 2 23 11]);
axes('parent',fh1,'unit','centimeters','position',[2 2 5 8],'fontsize',10); plot([1 2 3],y1,'linewidth',3,'Marker','.','MarkerSize',30); xlim([0.5 3.5]) ylim(ylim_range) set(gca,'XTick',[1 2 3],'yTickLabel',num2str(get(gca,'yTick')','%.1f')); xlabel("Filament","FontSize",FontSize,'FontName','Arial') ylabel("Mean of SN Radio","FontSize",FontSize,'FontName','Arial') box off
axes('parent',fh1,'unit','centimeters','position',[7 2 5 8],'fontsize',10); plot([240 250 260],y2,'linewidth',3,'Marker','.','MarkerSize',30); xlim([235 265]) ylim(ylim_range) set(gca,'XTick',[240 250 260],'YTickLabel','') xlabel("Speed(mm/s)","FontSize",FontSize,'FontName','Arial') box off
axes('parent',fh1,'unit','centimeters','position',[12 2 5 8],'fontsize',10); plot([210 215 220],y3,'linewidth',3,'Marker','.','MarkerSize',30) xlim([205 225]) ylim(ylim_range) set(gca,'XTick',[210 215 220],'YTickLabel','') xlabel("Temperature(\circC)","FontSize",FontSize,'FontName','Arial') box off
axes('parent',fh1,'unit','centimeters','position',[17 2 5 8],'fontsize',10); plot([0.16 0.20 0.24],y4,'linewidth',3,'Marker','.','MarkerSize',30) xlim([0.14 0.26]) ylim(ylim_range) set(gca,'XTick',[0.16 0.20 0.24],'YTickLabel','') xlabel("Layer thickness(mm)","FontSize",FontSize,'FontName','Arial') box off
ax2 = axes('parent',fh1,'unit','centimeters','position',[2 2 20 8],... 'XAxisLocation','top',... 'YAxisLocation','right',... 'Color','none',... 'XColor','k','YColor','k'); set(ax2,'YTick', []); set(ax2,'XTick', []);
X=[ones(size(A)) A B C D]; all_regress=cell(3,1); for ni=1:3 [b,~,~,~,stats] = regress(all_sigma(:,ni),X); all_regress{ni}=[{'' 'A' 'B' 'C' 'D' 'R^2' 'p-value'}',num2cell([b;stats([1 3])'])]; end
save all_regress_mat all_regress
|