bluebirdwtao 发表于 2007-5-27 13:38

如何画三维图并拟合?

以下是我自己写的代码,但是画出来的图不对(是线条样的),请教错在哪?如何更改?
另:如何画网格图?如何拟合?
A=[1 1 0.098
1 1.1 0.217
1 1.2 0.24
1 1.3 0.257
1 1.4 0.284
1 1.5 0.308
1 1.6 0.331
1 1.7 0.352
1 1.8 0.37
1 1.9 0.392
1 2 0.419
1 2.1 0.442
1 2.2 0.46
1 2.3 0.488
1 2.4 0.507
1 2.5 0.537
1 2.6 0.561
1 2.7 0.586
1 2.8 0.605
1 2.9 0.637
1 3 0.657
1.1 1 0.142
1.1 1.1 0.224
1.1 1.2 0.181
1.1 1.3 0.238
1.1 1.4 0.276
1.1 1.5 0.305
1.1 1.6 0.331
1.1 1.7 0.354
1.1 1.8 0.376
1.1 1.9 0.398
1.1 2 0.423
1.1 2.1 0.446
1.1 2.2 0.469
1.1 2.3 0.493
1.1 2.4 0.512
1.1 2.5 0.541
1.1 2.6 0.565
1.1 2.7 0.585
1.1 2.8 0.615
1.1 2.9 0.641
1.1 3 0.667
1.2 1 0.205
1.2 1.1 0.152
1.2 1.2 0.116
1.2 1.3 0.191
1.2 1.4 0.251
1.2 1.5 0.293
1.2 1.6 0.325
1.2 1.7 0.353
1.2 1.8 0.379
1.2 1.9 0.403
1.2 2 0.426
1.2 2.1 0.45
1.2 2.2 0.473
1.2 2.3 0.497
1.2 2.4 0.521
1.2 2.5 0.545
1.2 2.6 0.57
1.2 2.7 0.594
1.2 2.8 0.619
1.2 2.9 0.645
1.2 3 0.671
1.3 1 0.251
1.3 1.1 0.219
1.3 1.2 0.161
1.3 1.3 0.125
1.3 1.4 0.2
1.3 1.5 0.265
1.3 1.6 0.31
1.3 1.7 0.345
1.3 1.8 0.375
1.3 1.9 0.402
1.3 2 0.428
1.3 2.1 0.452
1.3 2.2 0.477
1.3 2.3 0.501
1.3 2.4 0.525
1.3 2.5 0.549
1.3 2.6 0.574
1.3 2.7 0.599
1.3 2.8 0.624
1.3 2.9 0.649
1.3 3 0.675
1.4 1 0.29
1.4 1.1 0.268
1.4 1.2 0.232
1.4 1.3 0.171
1.4 1.4 0.135
1.4 1.5 0.209
1.4 1.6 0.277
1.4 1.7 0.327
1.4 1.8 0.365
1.4 1.9 0.397
1.4 2 0.426
1.4 2.1 0.452
1.4 2.2 0.478
1.4 2.3 0.503
1.4 2.4 0.528
1.4 2.5 0.553
1.4 2.6 0.578
1.4 2.7 0.603
1.4 2.8 0.628
1.4 2.9 0.653
1.4 3 0.679
1.5 1 0.325
1.5 1.1 0.31
1.5 1.2 0.285
1.5 1.3 0.245
1.5 1.4 0.181
1.5 1.5 0.145
1.5 1.6 0.218
1.5 1.7 0.29
1.5 1.8 0.342
1.5 1.9 0.384
1.5 2 0.418
1.5 2.1 0.449
1.5 2.2 0.477
1.5 2.3 0.504
1.5 2.4 0.53
1.5 2.5 0.555
1.5 2.6 0.581
1.5 2.7 0.606
1.5 2.8 0.632
1.5 2.9 0.657
1.5 3 0.683
1.6 1 0.358
1.6 1.1 0.368
1.6 1.2 0.36
1.6 1.3 0.301
1.6 1.4 0.257
1.6 1.5 0.191
1.6 1.6 0.155
1.6 1.7 0.228
1.6 1.8 0.418
1.6 1.9 0.397
1.6 2 0.402
1.6 2.1 0.439
1.6 2.2 0.485
1.6 2.3 0.501
1.6 2.4 0.536
1.6 2.5 0.556
1.6 2.6 0.582
1.6 2.7 0.609
1.6 2.8 0.635
1.6 2.9 0.66
1.6 3 0.685
1.7 1 0.39
1.7 1.1 0.381
1.7 1.2 0.368
1.7 1.3 0.348
1.7 1.4 0.317
1.7 1.5 0.27
1.7 1.6 0.201
1.7 1.7 0.165
1.7 1.8 0.237
1.7 1.9 0.314
1.7 2 0.373
1.7 2.1 0.42
1.7 2.2 0.459
1.7 2.3 0.493
1.7 2.4 0.525
1.7 2.5 0.554
1.7 2.6 0.582
1.7 2.7 0.609
1.7 2.8 0.636
1.7 2.9 0.663
1.7 3 0.689
1.8 1 0.422
1.8 1.1 0.415
1.8 1.2 0.404
1.8 1.3 0.389
1.8 1.4 0.366
1.8 1.5 0.332
1.8 1.6 0.282
1.8 1.7 0.211
1.8 1.8 0.176
1.8 1.9 0.246
1.8 2 0.325
1.8 2.1 0.387
1.8 2.2 0.437
1.8 2.3 0.479
1.8 2.4 0.515
1.8 2.5 0.548
1.8 2.6 0.579
1.8 2.7 0.608
1.8 2.8 0.636
1.8 2.9 0.664
1.8 3 0.691
1.9 1 0.454
1.9 1.1 0.46
1.9 1.2 0.439
1.9 1.3 0.427
1.9 1.4 0.409
1.9 1.5 0.384
1.9 1.6 0.347
1.9 1.7 0.294
1.9 1.8 0.46
1.9 1.9 0.463
1.9 2 0.256
1.9 2.1 0.336
1.9 2.2 0.401
1.9 2.3 0.454
1.9 2.4 0.53
1.9 2.5 0.536
1.9 2.6 0.571
1.9 2.7 0.619
1.9 2.8 0.633
1.9 2.9 0.663
1.9 3 0.691
2 1 0.485
2 1.1 0.491
2 1.2 0.487
2 1.3 0.463
2 1.4 0.449
2 1.5 0.429
2 1.6 0.402
2 1.7 0.362
2 1.8 0.501
2 1.9 0.493
2 2 0.197
2 2.1 0.265
2 2.2 0.55
2 2.3 0.415
2 2.4 0.518
2 2.5 0.516
2 2.6 0.557
2 2.7 0.593
2 2.8 0.646
2 2.9 0.658
2 3 0.701
2.1 1 0.517
2.1 1.1 0.513
2.1 1.2 0.506
2.1 1.3 0.498
2.1 1.4 0.486
2.1 1.5 0.471
2.1 1.6 0.449
2.1 1.7 0.419
2.1 1.8 0.376
2.1 1.9 0.317
2.1 2 0.242
2.1 2.1 0.208
2.1 2.2 0.275
2.1 2.3 0.358
2.1 2.4 0.428
2.1 2.5 0.485
2.1 2.6 0.534
2.1 2.7 0.578
2.1 2.8 0.615
2.1 2.9 0.65
2.1 3 0.683
2.2 1 0.549
2.2 1.1 0.545
2.2 1.2 0.54
2.2 1.3 0.532
2.2 1.4 0.523
2.2 1.5 0.51
2.2 1.6 0.492
2.2 1.7 0.468
2.2 1.8 0.435
2.2 1.9 0.39
2.2 2 0.328
2.2 2.1 0.254
2.2 2.2 0.219
2.2 2.3 0.284
2.2 2.4 0.369
2.2 2.5 0.441
2.2 2.6 0.501
2.2 2.7 0.552
2.2 2.8 0.596
2.2 2.9 0.636
2.2 3 0.673
2.3 1 0.582
2.3 1.1 0.578
2.3 1.2 0.573
2.3 1.3 0.566
2.3 1.4 0.558
2.3 1.5 0.547
2.3 1.6 0.533
2.3 1.7 0.513
2.3 1.8 0.487
2.3 1.9 0.451
2.3 2 0.403
2.3 2.1 0.339
2.3 2.2 0.263
2.3 2.3 0.23
2.3 2.4 0.294
2.3 2.5 0.379
2.3 2.6 0.453
2.3 2.7 0.515
2.3 2.8 0.569
2.3 2.9 0.615
2.3 3 0.657
2.4 1 0.614
2.4 1.1 0.617
2.4 1.2 0.606
2.4 1.3 0.6
2.4 1.4 0.593
2.4 1.5 0.584
2.4 1.6 0.571
2.4 1.7 0.555
2.4 1.8 0.575
2.4 1.9 0.505
2.4 2 0.467
2.4 2.1 0.416
2.4 2.2 0.35
2.4 2.3 0.273
2.4 2.4 0.241
2.4 2.5 0.304
2.4 2.6 0.39
2.4 2.7 0.734
2.4 2.8 0.53
2.4 2.9 0.585
2.4 3 0.634
2.5 1 0.647
2.5 1.1 0.65
2.5 1.2 0.647
2.5 1.3 0.634
2.5 1.4 0.628
2.5 1.5 0.62
2.5 1.6 0.609
2.5 1.7 0.6
2.5 1.8 0.613
2.5 1.9 0.599
2.5 2 0.523
2.5 2.1 0.482
2.5 2.2 0.691
2.5 2.3 0.361
2.5 2.4 0.666
2.5 2.5 0.253
2.5 2.6 0.313
2.5 2.7 0.4
2.5 2.8 0.77
2.5 2.9 0.544
2.5 3 0.664
2.6 1 0.68
2.6 1.1 0.682
2.6 1.2 0.673
2.6 1.3 0.668
2.6 1.4 0.662
2.6 1.5 0.655
2.6 1.6 0.645
2.6 1.7 0.634
2.6 1.8 0.649
2.6 1.9 0.638
2.6 2 0.574
2.6 2.1 0.54
2.6 2.2 0.497
2.6 2.3 0.442
2.6 2.4 0.713
2.6 2.5 0.295
2.6 2.6 0.264
2.6 2.7 0.728
2.6 2.8 0.41
2.6 2.9 0.489
2.6 3 0.557
2.7 1 0.713
2.7 1.1 0.71
2.7 1.2 0.706
2.7 1.3 0.702
2.7 1.4 0.697
2.7 1.5 0.69
2.7 1.6 0.682
2.7 1.7 0.672
2.7 1.8 0.659
2.7 1.9 0.642
2.7 2 0.62
2.7 2.1 0.593
2.7 2.2 0.557
2.7 2.3 0.512
2.7 2.4 0.454
2.7 2.5 0.383
2.7 2.6 0.306
2.7 2.7 0.275
2.7 2.8 0.333
2.7 2.9 0.42
2.7 3 0.5
2.8 1 0.746
2.8 1.1 0.743
2.8 1.2 0.746
2.8 1.3 0.736
2.8 1.4 0.731
2.8 1.5 0.725
2.8 1.6 0.718
2.8 1.7 0.709
2.8 1.8 0.697
2.8 1.9 0.683
2.8 2 0.664
2.8 2.1 0.641
2.8 2.2 0.669
2.8 2.3 0.574
2.8 2.4 0.526
2.8 2.5 0.467
2.8 2.6 0.393
2.8 2.7 0.776
2.8 2.8 0.78
2.8 2.9 0.343
2.8 3 0.84
2.9 1 0.78
2.9 1.1 0.777
2.9 1.2 0.774
2.9 1.3 0.77
2.9 1.4 0.766
2.9 1.5 0.76
2.9 1.6 0.754
2.9 1.7 0.745
2.9 1.8 0.735
2.9 1.9 0.722
2.9 2 0.706
2.9 2.1 0.687
2.9 2.2 0.661
2.9 2.3 0.63
2.9 2.4 0.59
2.9 2.5 0.54
2.9 2.6 0.478
2.9 2.7 0.404
2.9 2.8 0.327
2.9 2.9 0.298
2.9 3 0.353
3 1 0.813
3 1.1 0.811
3 1.2 0.808
3 1.3 0.805
3 1.4 0.8
3 1.5 0.782
3 1.6 0.789
3 1.7 0.782
3 1.8 0.772
3 1.9 0.761
3 2 0.747
3 2.1 0.73
3 2.2 0.708
3 2.3 0.681
3 2.4 0.648
3 2.5 0.606
3 2.6 0.554
3 2.7 0.19
3 2.8 0.415
3 2.9 0.338
3 3 0.309
]
for i=1:441
    X(i)=A(i,1);
    Y(i)=A(i,2);
    Z(i)=A(i,3);
end
plot3(X,Y,Z)
xlabel('x-axis'),ylabel('y-axis'),zlabel('z-axis')

bluebirdwtao 发表于 2007-5-27 14:46

plot3画图我已经会了。请教其它问题

无水1324 发表于 2007-5-27 15:17

x=0:400:5600;%给出X轴的坐标
y=0:400:4800;%给出Y轴的坐标
z=[1350 1370 1390 1400 1410 96094088080069057043029021015
   1370 1390 1410 1430 1440 1140 1110 1050 95082069054038030021
   1380 1410 1430 1450 1470 1320 1280 1200 1080 94078062046037035
   1420 1430 1450 1480 1500 1550 1510 1430 1300 1200 98085075055050
   1430 1450 1460 1500 1550 1600 1550 1600 1600 1600 1550 1500 1500 1550 155
    950 1190 1370 1500 1200 1100 1550 1600 1550 1380 1070 9001050 1150 120
    910 1090 1270 1500 1200 1100 1350 1450 1200 1150 1010 8801000 1050 110
    880 1060 1230 1390 1500 1500 1400 9001100 1060 95087090093095
    830 9801180 1320 1450 1420 1400 1300 70090085084038078075
    740 8801080 1130 1250 1280 1230 1040 90050070078075065055
    650 7608809701020 1050 1020 83080070030050055048035
    510 62073080085087085078072065050020030035032
730 47055060067069067062058045040030010015025 ];
mesh(x,y,z)%绘制原数据图

=meshgrid(0:100:5600,0:100:4800);
Z=interp2(x,y,z,X,Y,'spline');%在坐标上进行样条插值
hold on
mesh(X,Y,Z) %加密后的地形图


给你一个类似的程序你看看

bluebirdwtao 发表于 2007-5-27 16:46

搞定了。谢谢你啊~~
页: [1]
查看完整版本: 如何画三维图并拟合?