یکی از پرکاربردی ترین توابعی که تا حالا توسعه دادم تابع divider هستش، کار این تابع اضافه کردن تعداد معینی نقاط دو بعدی و سه بعدی روی خطوط دو بعدی و سه بعدی هستش، این تابع در دو مد کار می کند، حالت منصفانه که در آن بسته به طول هر خط روی خم، تعداد نقاط را روی آن اضافه می‌کنه، حالت غیر منصفانه که در آن روی تمام خطوط یک خم بدون توجه به طول آن به یک اندازه نقاط جدید اضافه می‌کنه

 

 

نمونه اجرای زیر حالت غیر منصافنه و منصفانه فراخوانی این تابع را نشان می‌دهد:

 

کد این تابع برای حالت دو بعدی

%%%%%%%%%%%%%%%%%%%%%%%%%%-----------software details-----------%%%%%%%%%%%%%%%%%%%%%%

%devloped in Iran(ardebil)                                       %
%Copyright (C) 2017(1396) by moussa hasanzadeh as the head devloper %%
%All rights reserved.                                             % 
%programed in mathlab 2016                                 
%gmail:mo30no@gmail.com
%phone 09147082079


%%%%%%%%%%%%%%%%%----------published by http://wcnet.blog.ir/------------%%%%%%%%%%%%%%


 



%version 1.1
%isFair=1 adding points is based on distance isFair=0 adding of points based on edges
function   [X,Y]=divider(X,Y,n,isFair)



try
    if isFair==1
    else
        isFair=0 ;
    end
catch
    
isFair=0;
end
switch isFair
    case 0
T1=0;
T2=0;

for i=1:length(X)-1
    temp1=0;
    temp1=linspace(X(i),X(i+1),n+2)  ;
    
    T1=[T1,temp1(1:end-1)];
end
T1=[T1,temp1(end)];
X=T1(2:end);


for i=1:length(Y)-1
    temp2=0;
    temp2=linspace(Y(i),Y(i+1),n+2)  ;
    
    T2=[T2,temp2(1:end-1)];
end
T2=[T2,temp2(end)];
Y=T2(2:end);
    case 1

dists= sqrt( (X(2:end)-X(1:end-1)).^2 + (Y(2:end)-Y(1:end-1)).^2) ;


n1=round((dists./min(dists))*n);
T1=0;
T2=0;

for i=1:length(X)-1
  
    temp1=0;
    temp1=linspace(X(i),X(i+1),n1(i)+2)  ;
    
    T1=[T1,temp1(1:end-1)];
end
T1=[T1,temp1(end)];
X=T1(2:end);


for i=1:length(Y)-1
    temp2=0;
    temp2=linspace(Y(i),Y(i+1),n1(i)+2)  ;
    
    T2=[T2,temp2(1:end-1)];
end
T2=[T2,temp2(end)];
Y=T2(2:end);
end


end


%%%%%%%%%%%%%%%%%%%%%%%%%%-----------software details-----------%%%%%%%%%%%%%%%%%%%%%%

%devloped in Iran(ardebil)                                       %
%Copyright (C) 2017(1396) by moussa hasanzadeh as the head devloper %%
%All rights reserved.                                             % 
%programed in mathlab 2016                                 
%gmail:mo30no@gmail.com
%phone 09147082079

% here  u can make net objects, setting them and connect them togather, send message and capture them ,. the last version of this library will release at the end of 1397(2018)
% the last version will be a combnation of real and virtual environment for Analysiing of network as a good ,.
 
%%%%%%%%%%%%%%%%%----------published by http://wcnet.blog.ir/------------%%%%%%%%%%%%%%

 

اسکریپت فراخوانی این تابع، برای تنظیم مد منصفانه و غیر منصفانه به جای isFair  به ترتییب مقدار 1 و 0 قرار دهید. مقدار n هم تعداد را مشخص می کنه

 

  net=[];
  net.width=100;
  net.length=100;
  net.side=7;
  net.nodNum=200;
  ph=pi/net.side;
  
  t=linspace(0,2,net.side+1);
  
  x=sin(pi*t+ph); x=(((x-min(x))/(max(x)-min(x)))-0.5)* net.length;
  y=-cos(pi*t+ph);y=(((y-min(y))/(max(y)-min(y)))-0.5)*net.width;

  
figure;plot(x,y,'-*');
[X,Y]=divider(x,y,5,1);
figure;plot(X,Y,'-*');






  net=[];
  net.width=100;
  net.length=100;
  net.side=7;
  net.nodNum=200;
  ph=pi/net.side;
  
  t=linspace(0,2,net.side+1);
  
  x=[1,3,1.2,6,4]
    y=[4,0,12.2,3,1]

  
figure;plot(x,y,'-*');
[X,Y]=divider(x,y,5,1);
figure;plot(X,Y,'-*');
axis('equal')

 


مشخصات

  • جهت مشاهده منبع اصلی این مطلب کلیک کنید
  • کلمات کلیدی منبع : temp2 ,temp1 ,length ,side ,linspace ,isfair ,figure plot ,%%%%%%%%%%%%%%%%% published ,%phone 09147082079 ,%gmail mo30no@gmail ,http wcnet ,2016 %gmail mo30no@gmail ,%all rights reserved ,details %%%%%%%%%%%%%%%%%%%%%% %devloped ,software details %%%%%%%%%%%%%%%%%%%%%%
  • در صورتی که این صفحه دارای محتوای مجرمانه است یا درخواست حذف آن را دارید لطفا گزارش دهید.

تبلیغات

محل تبلیغات شما

آخرین مطالب این وبلاگ

محل تبلیغات شما محل تبلیغات شما

آخرین وبلاگ ها

برترین جستجو ها

آخرین جستجو ها

دختری از دنیای پاییز Letitica 800104 فولاد مارکت وبلاگ شعر عارف Megan وبسایت تخفیف گروهی آفکادو Jennings