MATLAB 3D玫瑰花绘制

参考博文:[Art & Science] 用python绘制3D花(二)
另:旋转版本在文章最后

目录

          • 1 玫瑰花绘制
            • 绘制效果
            • 完整代码
          • 2 月季花绘制
            • 绘制效果
            • 完整代码
          • 3 玫瑰配色
            • 颜色展示
            • 颜色数据自取
          • 4.旋转版本

1 玫瑰花绘制
绘制效果

MATLAB 3D玫瑰花绘制_第1张图片

完整代码
function drawrose
grid on
[x,t]=meshgrid((0:24)./24,(0:0.5:575)./575.*20.*pi+4*pi);
p=(pi/2)*exp(-t./(8*pi));
change=sin(15*t)/150;
u=1-(1-mod(3.6*t,2*pi)./pi).^4./2+change;
y=2*(x.^2-x).^2.*sin(p);

r=u.*(x.*sin(p)+y.*cos(p));
h=u.*(x.*cos(p)-y.*sin(p));

map=[0.9176    0.9412    1.0000
    0.9094    0.9341    0.9992
    0.9011    0.9271    0.9984
    0.8929    0.9200    0.9977
    0.8847    0.9130    0.9969
    0.8764    0.9059    0.9961
    0.8682    0.8988    0.9953
    0.8600    0.8918    0.9945
    0.8518    0.8847    0.9938
    0.8435    0.8777    0.9930
    0.8353    0.8706    0.9922
    0.8337    0.8698    0.9910
    0.8322    0.8690    0.9898
    0.8306    0.8682    0.9887
    0.8290    0.8674    0.9875
    0.8275    0.8667    0.9863
    0.8259    0.8659    0.9851
    0.8243    0.8651    0.9839
    0.8227    0.8643    0.9828
    0.8212    0.8635    0.9816
    0.8196    0.8627    0.9804
    0.8078    0.8521    0.9765
    0.7961    0.8415    0.9726
    0.7843    0.8310    0.9686
    0.7726    0.8204    0.9647
    0.7608    0.8098    0.9608
    0.7490    0.7992    0.9569
    0.7373    0.7886    0.9530
    0.7255    0.7781    0.9490
    0.7138    0.7675    0.9451
    0.7020    0.7569    0.9412
    0.6836    0.7400    0.9396
    0.6651    0.7232    0.9381
    0.6467    0.7063    0.9365
    0.6282    0.6894    0.9349
    0.6098    0.6725    0.9334
    0.5914    0.6557    0.9318
    0.5729    0.6388    0.9302
    0.5545    0.6219    0.9286
    0.5360    0.6051    0.9271
    0.5176    0.5882    0.9255
    0.5027    0.5776    0.9271
    0.4878    0.5670    0.9286
    0.4729    0.5565    0.9302
    0.4580    0.5459    0.9318
    0.4431    0.5353    0.9334
    0.4282    0.5247    0.9349
    0.4133    0.5141    0.9365
    0.3984    0.5036    0.9381
    0.3835    0.4930    0.9396
    0.3686    0.4824    0.9412
    0.3623    0.4742    0.9404
    0.3561    0.4659    0.9396
    0.3498    0.4577    0.9388
    0.3435    0.4494    0.9380
    0.3372    0.4412    0.9373
    0.3310    0.4330    0.9365
    0.3247    0.4247    0.9357
    0.3184    0.4165    0.9349
    0.3122    0.4082    0.9341
    0.3059    0.4000    0.9333
    0.2981    0.3918    0.9235
    0.2902    0.3835    0.9137
    0.2824    0.3753    0.9039
    0.2745    0.3670    0.8941
    0.2667    0.3588    0.8843
    0.2589    0.3506    0.8745
    0.2510    0.3423    0.8647
    0.2432    0.3341    0.8549
    0.2353    0.3258    0.8451
    0.2275    0.3176    0.8353
    0.2169    0.3086    0.8165
    0.2063    0.2996    0.7977
    0.1957    0.2906    0.7788
    0.1851    0.2816    0.7600
    0.1746    0.2726    0.7412
    0.1640    0.2635    0.7224
    0.1534    0.2545    0.7036
    0.1428    0.2455    0.6847
    0.1322    0.2365    0.6659
    0.1216    0.2275    0.6471];
set(gca,'CameraPosition',[2 2 2])
hold on
surface(r.*cos(t),r.*sin(t),h,'EdgeAlpha',0.1,...
    'EdgeColor',[0 0 0],'FaceColor','interp')
colormap(map)

end
2 月季花绘制
绘制效果

MATLAB 3D玫瑰花绘制_第2张图片
MATLAB 3D玫瑰花绘制_第3张图片

完整代码
function drawrose2
grid on
[x,t]=meshgrid((0:24)./24,(0:0.5:575)./575.*20.*pi-4*pi);
p=(pi/2)*exp(-t./(8*pi));
change=sin(20*t)/150;
u=1-(1-mod(3.3*t,2*pi)./pi).^4./2+change;
y=2*(x.^2-x).^2.*sin(p);

r=u.*(x.*sin(p)+y.*cos(p)).*1.5;
h=u.*(x.*cos(p)-y.*sin(p));

map=[0.9176    0.7490    0.3765
    0.9188    0.7513    0.3879
    0.9200    0.7537    0.3992
    0.9211    0.7560    0.4106
    0.9223    0.7584    0.4220
    0.9235    0.7608    0.4334
    0.9247    0.7631    0.4447
    0.9259    0.7654    0.4561
    0.9270    0.7678    0.4675
    0.9282    0.7702    0.4788
    0.9294    0.7725    0.4902
    0.9298    0.7698    0.5008
    0.9302    0.7670    0.5114
    0.9306    0.7643    0.5220
    0.9310    0.7615    0.5326
    0.9314    0.7588    0.5432
    0.9317    0.7561    0.5537
    0.9321    0.7533    0.5643
    0.9325    0.7506    0.5749
    0.9329    0.7478    0.5855
    0.9333    0.7451    0.5961
    0.9290    0.7404    0.5894
    0.9247    0.7357    0.5828
    0.9204    0.7310    0.5761
    0.9161    0.7263    0.5694
    0.9118    0.7215    0.5627
    0.9074    0.7168    0.5561
    0.9031    0.7121    0.5494
    0.8988    0.7074    0.5427
    0.8945    0.7027    0.5361
    0.8902    0.6980    0.5294
    0.8890    0.6976    0.5388
    0.8878    0.6972    0.5482
    0.8867    0.6968    0.5576
    0.8855    0.6964    0.5670
    0.8843    0.6961    0.5765
    0.8831    0.6957    0.5859
    0.8819    0.6953    0.5953
    0.8808    0.6949    0.6047
    0.8796    0.6945    0.6141
    0.8784    0.6941    0.6235
    0.8827    0.6988    0.6364
    0.8870    0.7035    0.6494
    0.8914    0.7082    0.6623
    0.8957    0.7129    0.6753
    0.9000    0.7177    0.6882
    0.9043    0.7224    0.7011
    0.9086    0.7271    0.7141
    0.9130    0.7318    0.7270
    0.9173    0.7365    0.7400
    0.9216    0.7412    0.7529
    0.9153    0.7275    0.7545
    0.9090    0.7137    0.7560
    0.9028    0.7000    0.7576
    0.8965    0.6863    0.7592
    0.8902    0.6725    0.7608
    0.8839    0.6588    0.7623
    0.8776    0.6451    0.7639
    0.8714    0.6314    0.7655
    0.8651    0.6176    0.7670
    0.8588    0.6039    0.7686
    0.8580    0.5906    0.7557
    0.8572    0.5772    0.7427
    0.8565    0.5639    0.7298
    0.8557    0.5506    0.7168
    0.8549    0.5373    0.7039
    0.8541    0.5239    0.6910
    0.8533    0.5106    0.6780
    0.8526    0.4973    0.6651
    0.8518    0.4839    0.6521
    0.8510    0.4706    0.6392
    0.8420    0.4447    0.6110
    0.8330    0.4188    0.5827
    0.8239    0.3930    0.5545
    0.8149    0.3671    0.5263
    0.8059    0.3412    0.4980
    0.7969    0.3153    0.4698
    0.7879    0.2894    0.4416
    0.7788    0.2636    0.4134
    0.7698    0.2377    0.3851
    0.7608    0.2118    0.3569];
set(gca,'CameraPosition',[2 2 2])
hold on
surface(r.*cos(t),r.*sin(t),h,'EdgeAlpha',0.1,...
    'EdgeColor',[0.5 0.5 0.5],'FaceColor','interp')
colormap(map)

end
3 玫瑰配色

代码中变量map的数值可改变以绘制不同颜色玫瑰,这里提供一部分自己取的颜色数据。


颜色展示

c1
在这里插入图片描述
c2
在这里插入图片描述
c3
在这里插入图片描述
c4
在这里插入图片描述
c5在这里插入图片描述
c6在这里插入图片描述
c7
在这里插入图片描述

颜色数据自取
c1=[1.0000    0.6471    0.8275
    0.9984    0.6353    0.8130
    0.9969    0.6236    0.7985
    0.9953    0.6118    0.7840
    0.9937    0.6000    0.7695
    0.9921    0.5882    0.7550
    0.9906    0.5765    0.7404
    0.9890    0.5647    0.7259
    0.9874    0.5529    0.7114
    0.9859    0.5412    0.6969
    0.9843    0.5294    0.6824
    0.9757    0.5149    0.6730
    0.9670    0.5004    0.6636
    0.9584    0.4859    0.6541
    0.9498    0.4714    0.6447
    0.9411    0.4568    0.6353
    0.9325    0.4423    0.6259
    0.9239    0.4278    0.6165
    0.9153    0.4133    0.6070
    0.9066    0.3988    0.5976
    0.8980    0.3843    0.5882
    0.8937    0.3780    0.5756
    0.8894    0.3718    0.5631
    0.8851    0.3655    0.5505
    0.8808    0.3592    0.5380
    0.8764    0.3529    0.5254
    0.8721    0.3467    0.5129
    0.8678    0.3404    0.5003
    0.8635    0.3341    0.4878
    0.8592    0.3279    0.4752
    0.8549    0.3216    0.4627
    0.8561    0.3165    0.4596
    0.8573    0.3114    0.4564
    0.8584    0.3063    0.4533
    0.8596    0.3012    0.4502
    0.8608    0.2961    0.4471
    0.8620    0.2910    0.4439
    0.8632    0.2859    0.4408
    0.8643    0.2808    0.4377
    0.8655    0.2757    0.4345
    0.8667    0.2706    0.4314
    0.8549    0.2620    0.4165
    0.8432    0.2533    0.4016
    0.8314    0.2447    0.3867
    0.8196    0.2361    0.3718
    0.8078    0.2274    0.3569
    0.7961    0.2188    0.3420
    0.7843    0.2102    0.3271
    0.7725    0.2016    0.3122
    0.7608    0.1929    0.2973
    0.7490    0.1843    0.2824
    0.7553    0.1827    0.2855
    0.7616    0.1812    0.2887
    0.7678    0.1796    0.2918
    0.7741    0.1780    0.2949
    0.7804    0.1764    0.2980
    0.7867    0.1749    0.3012
    0.7930    0.1733    0.3043
    0.7992    0.1717    0.3074
    0.8055    0.1702    0.3106
    0.8118    0.1686    0.3137
    0.7977    0.1631    0.3023
    0.7836    0.1576    0.2910
    0.7694    0.1521    0.2796
    0.7553    0.1466    0.2682
    0.7412    0.1411    0.2569
    0.7271    0.1357    0.2455
    0.7130    0.1302    0.2341
    0.6988    0.1247    0.2227
    0.6847    0.1192    0.2114
    0.6706    0.1137    0.2000
    0.6686    0.1141    0.1996
    0.6667    0.1145    0.1992
    0.6647    0.1149    0.1988
    0.6628    0.1153    0.1984
    0.6608    0.1157    0.1981
    0.6588    0.1160    0.1977
    0.6569    0.1164    0.1973
    0.6549    0.1168    0.1969
    0.6530    0.1172    0.1965
    0.6510    0.1176    0.1961];
c2=[0.2000    0.0941    0.3569
    0.2063    0.0906    0.3663
    0.2125    0.0870    0.3757
    0.2188    0.0835    0.3851
    0.2251    0.0800    0.3945
    0.2314    0.0765    0.4040
    0.2376    0.0729    0.4134
    0.2439    0.0694    0.4228
    0.2502    0.0659    0.4322
    0.2564    0.0623    0.4416
    0.2627    0.0588    0.4510
    0.2670    0.0608    0.4537
    0.2713    0.0627    0.4565
    0.2757    0.0647    0.4592
    0.2800    0.0666    0.4620
    0.2843    0.0686    0.4647
    0.2886    0.0706    0.4674
    0.2929    0.0725    0.4702
    0.2973    0.0745    0.4729
    0.3016    0.0764    0.4757
    0.3059    0.0784    0.4784
    0.3267    0.0855    0.4811
    0.3475    0.0925    0.4839
    0.3682    0.0996    0.4866
    0.3890    0.1066    0.4894
    0.4098    0.1137    0.4921
    0.4306    0.1208    0.4949
    0.4514    0.1278    0.4977
    0.4721    0.1349    0.5004
    0.4929    0.1419    0.5031
    0.5137    0.1490    0.5059
    0.5255    0.1529    0.5055
    0.5372    0.1568    0.5051
    0.5490    0.1608    0.5047
    0.5608    0.1647    0.5043
    0.5726    0.1686    0.5040
    0.5843    0.1725    0.5036
    0.5961    0.1764    0.5032
    0.6079    0.1804    0.5028
    0.6196    0.1843    0.5024
    0.6314    0.1882    0.5020
    0.6553    0.1984    0.4949
    0.6792    0.2086    0.4879
    0.7032    0.2188    0.4808
    0.7271    0.2290    0.4738
    0.7510    0.2392    0.4667
    0.7749    0.2494    0.4596
    0.7988    0.2596    0.4526
    0.8228    0.2698    0.4455
    0.8467    0.2800    0.4385
    0.8706    0.2902    0.4314
    0.8765    0.3024    0.4247
    0.8824    0.3145    0.4181
    0.8882    0.3267    0.4114
    0.8941    0.3388    0.4047
    0.9000    0.3510    0.3981
    0.9059    0.3632    0.3914
    0.9118    0.3753    0.3847
    0.9176    0.3875    0.3780
    0.9235    0.3996    0.3714
    0.9294    0.4118    0.3647
    0.9341    0.4228    0.3659
    0.9388    0.4338    0.3671
    0.9435    0.4447    0.3682
    0.9482    0.4557    0.3694
    0.9529    0.4667    0.3706
    0.9577    0.4777    0.3718
    0.9624    0.4887    0.3730
    0.9671    0.4996    0.3741
    0.9718    0.5106    0.3753
    0.9765    0.5216    0.3765
    0.9785    0.5259    0.3808
    0.9804    0.5302    0.3851
    0.9824    0.5345    0.3894
    0.9843    0.5388    0.3937
    0.9863    0.5432    0.3981
    0.9883    0.5475    0.4024
    0.9902    0.5518    0.4067
    0.9922    0.5561    0.4110
    0.9941    0.5604    0.4153
    0.9961    0.5647    0.4196
    0.9965    0.5718    0.4224
    0.9969    0.5788    0.4251
    0.9973    0.5859    0.4279
    0.9977    0.5929    0.4306
    0.9980    0.6000    0.4334
    0.9984    0.6071    0.4361
    0.9988    0.6141    0.4388
    0.9992    0.6212    0.4416
    0.9996    0.6282    0.4443
    1.0000    0.6353    0.4471
    0.9992    0.6467    0.4549
    0.9984    0.6580    0.4628
    0.9977    0.6694    0.4706
    0.9969    0.6808    0.4785
    0.9961    0.6922    0.4863
    0.9953    0.7035    0.4941
    0.9945    0.7149    0.5020
    0.9938    0.7263    0.5098
    0.9930    0.7376    0.5177
    0.9922    0.7490    0.5255
    0.9930    0.7639    0.5380
    0.9938    0.7788    0.5506
    0.9945    0.7937    0.5632
    0.9953    0.8086    0.5757
    0.9961    0.8235    0.5882
    0.9969    0.8384    0.6008
    0.9977    0.8533    0.6133
    0.9984    0.8682    0.6259
    0.9992    0.8831    0.6384
    1.0000    0.8980    0.6510
    0.9984    0.9035    0.6565
    0.9969    0.9090    0.6620
    0.9953    0.9145    0.6675
    0.9937    0.9200    0.6730
    0.9921    0.9254    0.6784
    0.9906    0.9309    0.6839
    0.9890    0.9364    0.6894
    0.9874    0.9419    0.6949
    0.9859    0.9474    0.7004
    0.9843    0.9529    0.7059];
c3=[0.9176    0.9412    1.0000
    0.9094    0.9341    0.9992
    0.9011    0.9271    0.9984
    0.8929    0.9200    0.9977
    0.8847    0.9130    0.9969
    0.8764    0.9059    0.9961
    0.8682    0.8988    0.9953
    0.8600    0.8918    0.9945
    0.8518    0.8847    0.9938
    0.8435    0.8777    0.9930
    0.8353    0.8706    0.9922
    0.8337    0.8698    0.9910
    0.8322    0.8690    0.9898
    0.8306    0.8682    0.9887
    0.8290    0.8674    0.9875
    0.8275    0.8667    0.9863
    0.8259    0.8659    0.9851
    0.8243    0.8651    0.9839
    0.8227    0.8643    0.9828
    0.8212    0.8635    0.9816
    0.8196    0.8627    0.9804
    0.8078    0.8521    0.9765
    0.7961    0.8415    0.9726
    0.7843    0.8310    0.9686
    0.7726    0.8204    0.9647
    0.7608    0.8098    0.9608
    0.7490    0.7992    0.9569
    0.7373    0.7886    0.9530
    0.7255    0.7781    0.9490
    0.7138    0.7675    0.9451
    0.7020    0.7569    0.9412
    0.6836    0.7400    0.9396
    0.6651    0.7232    0.9381
    0.6467    0.7063    0.9365
    0.6282    0.6894    0.9349
    0.6098    0.6725    0.9334
    0.5914    0.6557    0.9318
    0.5729    0.6388    0.9302
    0.5545    0.6219    0.9286
    0.5360    0.6051    0.9271
    0.5176    0.5882    0.9255
    0.5027    0.5776    0.9271
    0.4878    0.5670    0.9286
    0.4729    0.5565    0.9302
    0.4580    0.5459    0.9318
    0.4431    0.5353    0.9334
    0.4282    0.5247    0.9349
    0.4133    0.5141    0.9365
    0.3984    0.5036    0.9381
    0.3835    0.4930    0.9396
    0.3686    0.4824    0.9412
    0.3623    0.4742    0.9404
    0.3561    0.4659    0.9396
    0.3498    0.4577    0.9388
    0.3435    0.4494    0.9380
    0.3372    0.4412    0.9373
    0.3310    0.4330    0.9365
    0.3247    0.4247    0.9357
    0.3184    0.4165    0.9349
    0.3122    0.4082    0.9341
    0.3059    0.4000    0.9333
    0.2981    0.3918    0.9235
    0.2902    0.3835    0.9137
    0.2824    0.3753    0.9039
    0.2745    0.3670    0.8941
    0.2667    0.3588    0.8843
    0.2589    0.3506    0.8745
    0.2510    0.3423    0.8647
    0.2432    0.3341    0.8549
    0.2353    0.3258    0.8451
    0.2275    0.3176    0.8353
    0.2169    0.3086    0.8165
    0.2063    0.2996    0.7977
    0.1957    0.2906    0.7788
    0.1851    0.2816    0.7600
    0.1746    0.2726    0.7412
    0.1640    0.2635    0.7224
    0.1534    0.2545    0.7036
    0.1428    0.2455    0.6847
    0.1322    0.2365    0.6659
    0.1216    0.2275    0.6471];
c4=[0.9176    0.7490    0.3765
    0.9188    0.7513    0.3879
    0.9200    0.7537    0.3992
    0.9211    0.7560    0.4106
    0.9223    0.7584    0.4220
    0.9235    0.7608    0.4334
    0.9247    0.7631    0.4447
    0.9259    0.7654    0.4561
    0.9270    0.7678    0.4675
    0.9282    0.7702    0.4788
    0.9294    0.7725    0.4902
    0.9298    0.7698    0.5008
    0.9302    0.7670    0.5114
    0.9306    0.7643    0.5220
    0.9310    0.7615    0.5326
    0.9314    0.7588    0.5432
    0.9317    0.7561    0.5537
    0.9321    0.7533    0.5643
    0.9325    0.7506    0.5749
    0.9329    0.7478    0.5855
    0.9333    0.7451    0.5961
    0.9290    0.7404    0.5894
    0.9247    0.7357    0.5828
    0.9204    0.7310    0.5761
    0.9161    0.7263    0.5694
    0.9118    0.7215    0.5627
    0.9074    0.7168    0.5561
    0.9031    0.7121    0.5494
    0.8988    0.7074    0.5427
    0.8945    0.7027    0.5361
    0.8902    0.6980    0.5294
    0.8890    0.6976    0.5388
    0.8878    0.6972    0.5482
    0.8867    0.6968    0.5576
    0.8855    0.6964    0.5670
    0.8843    0.6961    0.5765
    0.8831    0.6957    0.5859
    0.8819    0.6953    0.5953
    0.8808    0.6949    0.6047
    0.8796    0.6945    0.6141
    0.8784    0.6941    0.6235
    0.8827    0.6988    0.6364
    0.8870    0.7035    0.6494
    0.8914    0.7082    0.6623
    0.8957    0.7129    0.6753
    0.9000    0.7177    0.6882
    0.9043    0.7224    0.7011
    0.9086    0.7271    0.7141
    0.9130    0.7318    0.7270
    0.9173    0.7365    0.7400
    0.9216    0.7412    0.7529
    0.9153    0.7275    0.7545
    0.9090    0.7137    0.7560
    0.9028    0.7000    0.7576
    0.8965    0.6863    0.7592
    0.8902    0.6725    0.7608
    0.8839    0.6588    0.7623
    0.8776    0.6451    0.7639
    0.8714    0.6314    0.7655
    0.8651    0.6176    0.7670
    0.8588    0.6039    0.7686
    0.8580    0.5906    0.7557
    0.8572    0.5772    0.7427
    0.8565    0.5639    0.7298
    0.8557    0.5506    0.7168
    0.8549    0.5373    0.7039
    0.8541    0.5239    0.6910
    0.8533    0.5106    0.6780
    0.8526    0.4973    0.6651
    0.8518    0.4839    0.6521
    0.8510    0.4706    0.6392
    0.8420    0.4447    0.6110
    0.8330    0.4188    0.5827
    0.8239    0.3930    0.5545
    0.8149    0.3671    0.5263
    0.8059    0.3412    0.4980
    0.7969    0.3153    0.4698
    0.7879    0.2894    0.4416
    0.7788    0.2636    0.4134
    0.7698    0.2377    0.3851
    0.7608    0.2118    0.3569];
c5=[0.3451    0.1020    0.1451
    0.3667    0.1126    0.1616
    0.3882    0.1232    0.1780
    0.4098    0.1337    0.1945
    0.4314    0.1443    0.2110
    0.4529    0.1549    0.2275
    0.4745    0.1655    0.2439
    0.4961    0.1761    0.2604
    0.5177    0.1866    0.2769
    0.5392    0.1972    0.2933
    0.5608    0.2078    0.3098
    0.5675    0.2204    0.3200
    0.5741    0.2329    0.3302
    0.5808    0.2454    0.3404
    0.5875    0.2580    0.3506
    0.5941    0.2706    0.3608
    0.6008    0.2831    0.3710
    0.6075    0.2957    0.3812
    0.6142    0.3082    0.3914
    0.6208    0.3208    0.4016
    0.6275    0.3333    0.4118
    0.6318    0.3388    0.4173
    0.6361    0.3443    0.4228
    0.6404    0.3498    0.4283
    0.6447    0.3553    0.4338
    0.6490    0.3608    0.4393
    0.6534    0.3662    0.4447
    0.6577    0.3717    0.4502
    0.6620    0.3772    0.4557
    0.6663    0.3827    0.4612
    0.6706    0.3882    0.4667
    0.6788    0.4007    0.4785
    0.6871    0.4133    0.4902
    0.6953    0.4259    0.5020
    0.7035    0.4384    0.5137
    0.7117    0.4510    0.5255
    0.7200    0.4635    0.5373
    0.7282    0.4760    0.5490
    0.7364    0.4886    0.5608
    0.7447    0.5012    0.5725
    0.7529    0.5137    0.5843
    0.7584    0.5223    0.5921
    0.7639    0.5310    0.6000
    0.7694    0.5396    0.6078
    0.7749    0.5482    0.6157
    0.7803    0.5569    0.6235
    0.7858    0.5655    0.6313
    0.7913    0.5741    0.6392
    0.7968    0.5827    0.6470
    0.8023    0.5914    0.6549
    0.8078    0.6000    0.6627
    0.8090    0.6086    0.6705
    0.8102    0.6173    0.6784
    0.8113    0.6259    0.6862
    0.8125    0.6345    0.6941
    0.8137    0.6431    0.7019
    0.8149    0.6518    0.7098
    0.8161    0.6604    0.7176
    0.8172    0.6690    0.7255
    0.8184    0.6777    0.7333
    0.8196    0.6863    0.7412
    0.8192    0.6832    0.7388
    0.8188    0.6800    0.7365
    0.8184    0.6769    0.7341
    0.8180    0.6737    0.7318
    0.8176    0.6706    0.7294
    0.8173    0.6675    0.7270
    0.8169    0.6643    0.7247
    0.8165    0.6612    0.7223
    0.8161    0.6580    0.7200
    0.8157    0.6549    0.7176];
c6=[0.3451    0.6275    0.7255
    0.3557    0.6314    0.7275
    0.3663    0.6353    0.7294
    0.3769    0.6393    0.7314
    0.3875    0.6432    0.7333
    0.3981    0.6471    0.7353
    0.4086    0.6510    0.7373
    0.4192    0.6549    0.7392
    0.4298    0.6589    0.7412
    0.4404    0.6628    0.7431
    0.4510    0.6667    0.7451
    0.4592    0.6675    0.7428
    0.4675    0.6683    0.7404
    0.4757    0.6690    0.7380
    0.4839    0.6698    0.7357
    0.4921    0.6706    0.7333
    0.5004    0.6714    0.7310
    0.5086    0.6722    0.7287
    0.5168    0.6729    0.7263
    0.5251    0.6737    0.7239
    0.5333    0.6745    0.7216
    0.5400    0.6761    0.7208
    0.5466    0.6776    0.7200
    0.5533    0.6792    0.7192
    0.5600    0.6808    0.7184
    0.5666    0.6824    0.7177
    0.5733    0.6839    0.7169
    0.5800    0.6855    0.7161
    0.5867    0.6871    0.7153
    0.5933    0.6886    0.7145
    0.6000    0.6902    0.7137
    0.6071    0.6941    0.7172
    0.6141    0.6980    0.7208
    0.6212    0.7020    0.7243
    0.6282    0.7059    0.7278
    0.6353    0.7098    0.7313
    0.6424    0.7137    0.7349
    0.6494    0.7176    0.7384
    0.6565    0.7216    0.7419
    0.6635    0.7255    0.7455
    0.6706    0.7294    0.7490
    0.6773    0.7357    0.7545
    0.6839    0.7420    0.7600
    0.6906    0.7482    0.7655
    0.6973    0.7545    0.7710
    0.7039    0.7608    0.7764
    0.7106    0.7671    0.7819
    0.7173    0.7734    0.7874
    0.7240    0.7796    0.7929
    0.7306    0.7859    0.7984
    0.7373    0.7922    0.8039
    0.7483    0.7926    0.8008
    0.7593    0.7930    0.7976
    0.7702    0.7934    0.7945
    0.7812    0.7938    0.7913
    0.7922    0.7942    0.7882
    0.8032    0.7945    0.7851
    0.8142    0.7949    0.7819
    0.8251    0.7953    0.7788
    0.8361    0.7957    0.7756
    0.8471    0.7961    0.7725
    0.8498    0.7973    0.7733
    0.8526    0.7984    0.7741
    0.8553    0.7996    0.7749
    0.8581    0.8008    0.7757
    0.8608    0.8019    0.7764
    0.8635    0.8031    0.7772
    0.8663    0.8043    0.7780
    0.8690    0.8055    0.7788
    0.8718    0.8066    0.7796
    0.8745    0.8078    0.7804];
c7=[0.5922    0.7098    0.7490
    0.6051    0.7094    0.7435
    0.6181    0.7090    0.7380
    0.6310    0.7086    0.7325
    0.6440    0.7082    0.7270
    0.6569    0.7078    0.7216
    0.6698    0.7075    0.7161
    0.6828    0.7071    0.7106
    0.6957    0.7067    0.7051
    0.7087    0.7063    0.6996
    0.7216    0.7059    0.6941
    0.7314    0.7090    0.6965
    0.7412    0.7122    0.6988
    0.7510    0.7153    0.7012
    0.7608    0.7185    0.7035
    0.7706    0.7216    0.7059
    0.7804    0.7247    0.7082
    0.7902    0.7279    0.7106
    0.8000    0.7310    0.7129
    0.8098    0.7342    0.7153
    0.8196    0.7373    0.7176
    0.8372    0.7432    0.7172
    0.8549    0.7491    0.7168
    0.8726    0.7549    0.7164
    0.8902    0.7608    0.7160
    0.9079    0.7667    0.7157
    0.9255    0.7726    0.7153
    0.9432    0.7785    0.7149
    0.9608    0.7843    0.7145
    0.9785    0.7902    0.7141
    0.9961    0.7961    0.7137
    0.9965    0.7937    0.7102
    0.9969    0.7914    0.7066
    0.9973    0.7890    0.7031
    0.9977    0.7867    0.6996
    0.9980    0.7843    0.6961
    0.9984    0.7819    0.6925
    0.9988    0.7796    0.6890
    0.9992    0.7772    0.6855
    0.9996    0.7749    0.6819
    1.0000    0.7725    0.6784
    1.0000    0.7643    0.6713
    1.0000    0.7560    0.6643
    1.0000    0.7478    0.6572
    1.0000    0.7396    0.6502
    1.0000    0.7313    0.6431
    1.0000    0.7231    0.6360
    1.0000    0.7149    0.6290
    1.0000    0.7067    0.6219
    1.0000    0.6984    0.6149
    1.0000    0.6902    0.6078
    0.9996    0.6824    0.5968
    0.9992    0.6745    0.5858
    0.9988    0.6667    0.5749
    0.9984    0.6588    0.5639
    0.9980    0.6510    0.5529
    0.9977    0.6432    0.5419
    0.9973    0.6353    0.5309
    0.9969    0.6275    0.5200
    0.9965    0.6196    0.5090
    0.9961    0.6118    0.4980
    0.9965    0.6067    0.4909
    0.9969    0.6016    0.4839
    0.9973    0.5965    0.4768
    0.9977    0.5914    0.4698
    0.9980    0.5863    0.4627
    0.9984    0.5812    0.4557
    0.9988    0.5761    0.4486
    0.9992    0.5710    0.4416
    0.9996    0.5659    0.4346
    1.0000    0.5608    0.4275
    0.9969    0.5522    0.4173
    0.9937    0.5435    0.4071
    0.9906    0.5349    0.3969
    0.9874    0.5263    0.3867
    0.9843    0.5176    0.3765
    0.9812    0.5090    0.3663
    0.9780    0.5004    0.3561
    0.9749    0.4918    0.3459
    0.9717    0.4831    0.3357
    0.9686    0.4745    0.3255];
4.旋转版本

改动很小,就是最后一小段稍有变动

function drawrose2
grid on
[x,t]=meshgrid((0:24)./24,(0:0.5:575)./575.*20.*pi-4*pi);
p=(pi/2)*exp(-t./(8*pi));
change=sin(20*t)/150;
u=1-(1-mod(3.3*t,2*pi)./pi).^4./2+change;
y=2*(x.^2-x).^2.*sin(p);

r=u.*(x.*sin(p)+y.*cos(p)).*1.5;
h=u.*(x.*cos(p)-y.*sin(p));

map=[0.9176    0.7490    0.3765
    0.9188    0.7513    0.3879
    0.9200    0.7537    0.3992
    0.9211    0.7560    0.4106
    0.9223    0.7584    0.4220
    0.9235    0.7608    0.4334
    0.9247    0.7631    0.4447
    0.9259    0.7654    0.4561
    0.9270    0.7678    0.4675
    0.9282    0.7702    0.4788
    0.9294    0.7725    0.4902
    0.9298    0.7698    0.5008
    0.9302    0.7670    0.5114
    0.9306    0.7643    0.5220
    0.9310    0.7615    0.5326
    0.9314    0.7588    0.5432
    0.9317    0.7561    0.5537
    0.9321    0.7533    0.5643
    0.9325    0.7506    0.5749
    0.9329    0.7478    0.5855
    0.9333    0.7451    0.5961
    0.9290    0.7404    0.5894
    0.9247    0.7357    0.5828
    0.9204    0.7310    0.5761
    0.9161    0.7263    0.5694
    0.9118    0.7215    0.5627
    0.9074    0.7168    0.5561
    0.9031    0.7121    0.5494
    0.8988    0.7074    0.5427
    0.8945    0.7027    0.5361
    0.8902    0.6980    0.5294
    0.8890    0.6976    0.5388
    0.8878    0.6972    0.5482
    0.8867    0.6968    0.5576
    0.8855    0.6964    0.5670
    0.8843    0.6961    0.5765
    0.8831    0.6957    0.5859
    0.8819    0.6953    0.5953
    0.8808    0.6949    0.6047
    0.8796    0.6945    0.6141
    0.8784    0.6941    0.6235
    0.8827    0.6988    0.6364
    0.8870    0.7035    0.6494
    0.8914    0.7082    0.6623
    0.8957    0.7129    0.6753
    0.9000    0.7177    0.6882
    0.9043    0.7224    0.7011
    0.9086    0.7271    0.7141
    0.9130    0.7318    0.7270
    0.9173    0.7365    0.7400
    0.9216    0.7412    0.7529
    0.9153    0.7275    0.7545
    0.9090    0.7137    0.7560
    0.9028    0.7000    0.7576
    0.8965    0.6863    0.7592
    0.8902    0.6725    0.7608
    0.8839    0.6588    0.7623
    0.8776    0.6451    0.7639
    0.8714    0.6314    0.7655
    0.8651    0.6176    0.7670
    0.8588    0.6039    0.7686
    0.8580    0.5906    0.7557
    0.8572    0.5772    0.7427
    0.8565    0.5639    0.7298
    0.8557    0.5506    0.7168
    0.8549    0.5373    0.7039
    0.8541    0.5239    0.6910
    0.8533    0.5106    0.6780
    0.8526    0.4973    0.6651
    0.8518    0.4839    0.6521
    0.8510    0.4706    0.6392
    0.8420    0.4447    0.6110
    0.8330    0.4188    0.5827
    0.8239    0.3930    0.5545
    0.8149    0.3671    0.5263
    0.8059    0.3412    0.4980
    0.7969    0.3153    0.4698
    0.7879    0.2894    0.4416
    0.7788    0.2636    0.4134
    0.7698    0.2377    0.3851
    0.7608    0.2118    0.3569];
set(gca,'CameraPosition',[2 2 2])
hold on
Xset=r.*cos(t);Yset=r.*sin(t);
sf=surface(Xset,Yset,h,'EdgeAlpha',0.1,...
    'EdgeColor',[0.5 0.5 0.5],'FaceColor','interp');
colormap(map)


theta=0;
while 1
    theta=theta+0.02;
    set(sf,'XData',Xset.*cos(theta)-Yset.*sin(theta),...
        'YData',Xset.*sin(theta)+Yset.*cos(theta))
    pause(0.01)
end


end

你可能感兴趣的:(matlab,绘图,3D,玫瑰,数据)