Two questions related to Matlab Coding












-1















  1. How can I make code in Matlab that calculates how many storm tracks pass the line, or how many do not pass, or how many overlap with each other (storm track and line)?


  2. How can I make code in Matlab that calculates the angle between the storm track and lines that are overlapped?
    I already tried but it’s not working.



    N = 50; % Number of events  
    X = 50; Y = 50;

    P1x = rand(N,1) * X;
    P1y = rand(N,1) * Y ; % initial point

    L = lognrnd(2,0.7,[N,1]); % Sample track length
    Theta = mod(normrnd(90,15,[N,1]),360);

    dx = L.*cos(deg2rad(Theta - 90));
    dy = L.*sin(deg2rad(Theta - 270));

    P2x = P1x + dx; P2y = P1y + dy; % Final point

    plot([0 X X 0 0],[0 0 Y Y 0]); hold on

    for j = 1:N
    plot(P1x(j),P1y(j),'ro')
    plot([P1x(j) P2x(j)],[P1y(j) P2y(j)],'-')
    end

    k=line([(X+Y)/2.25, (X+Y)/3, (X+Y)/3, (X+Y)/4] , [0, (X+Y)/10, (X+Y)/2.5, (X+Y)/2]);

    xlabel('X [km]'); ylabel('Y [km]');
    xlim([-X/4 1.25*X]); ylim([-Y/4 1.25*Y])



plot screenshot










share|improve this question
























  • There is no legend in your plot....why don't you tell us..what you want from figure? Is it the points (red circles) intersecting the blue box? Be clear. Specify what is a track and what is a line here?
    – Siva Srinivas Kolukula
    Nov 16 at 3:50










  • here, i already generate 50 storm track randomly. (if you run this code then you might be understand). red circles are the initial point of the storm track which is passes from left to right direction towards the blue line and blue line is the line structures (assumes). i need to know how many storm track will pass this blue line (that means line structures) how many not and also how many intersect? also if the storm track and line intersects each other then what is the angle between this two ? whole process has to be made through Matlab? i hope you will understand now @SivaSrinivas
    – Razib
    Nov 16 at 4:32
















-1















  1. How can I make code in Matlab that calculates how many storm tracks pass the line, or how many do not pass, or how many overlap with each other (storm track and line)?


  2. How can I make code in Matlab that calculates the angle between the storm track and lines that are overlapped?
    I already tried but it’s not working.



    N = 50; % Number of events  
    X = 50; Y = 50;

    P1x = rand(N,1) * X;
    P1y = rand(N,1) * Y ; % initial point

    L = lognrnd(2,0.7,[N,1]); % Sample track length
    Theta = mod(normrnd(90,15,[N,1]),360);

    dx = L.*cos(deg2rad(Theta - 90));
    dy = L.*sin(deg2rad(Theta - 270));

    P2x = P1x + dx; P2y = P1y + dy; % Final point

    plot([0 X X 0 0],[0 0 Y Y 0]); hold on

    for j = 1:N
    plot(P1x(j),P1y(j),'ro')
    plot([P1x(j) P2x(j)],[P1y(j) P2y(j)],'-')
    end

    k=line([(X+Y)/2.25, (X+Y)/3, (X+Y)/3, (X+Y)/4] , [0, (X+Y)/10, (X+Y)/2.5, (X+Y)/2]);

    xlabel('X [km]'); ylabel('Y [km]');
    xlim([-X/4 1.25*X]); ylim([-Y/4 1.25*Y])



plot screenshot










share|improve this question
























  • There is no legend in your plot....why don't you tell us..what you want from figure? Is it the points (red circles) intersecting the blue box? Be clear. Specify what is a track and what is a line here?
    – Siva Srinivas Kolukula
    Nov 16 at 3:50










  • here, i already generate 50 storm track randomly. (if you run this code then you might be understand). red circles are the initial point of the storm track which is passes from left to right direction towards the blue line and blue line is the line structures (assumes). i need to know how many storm track will pass this blue line (that means line structures) how many not and also how many intersect? also if the storm track and line intersects each other then what is the angle between this two ? whole process has to be made through Matlab? i hope you will understand now @SivaSrinivas
    – Razib
    Nov 16 at 4:32














-1












-1








-1








  1. How can I make code in Matlab that calculates how many storm tracks pass the line, or how many do not pass, or how many overlap with each other (storm track and line)?


  2. How can I make code in Matlab that calculates the angle between the storm track and lines that are overlapped?
    I already tried but it’s not working.



    N = 50; % Number of events  
    X = 50; Y = 50;

    P1x = rand(N,1) * X;
    P1y = rand(N,1) * Y ; % initial point

    L = lognrnd(2,0.7,[N,1]); % Sample track length
    Theta = mod(normrnd(90,15,[N,1]),360);

    dx = L.*cos(deg2rad(Theta - 90));
    dy = L.*sin(deg2rad(Theta - 270));

    P2x = P1x + dx; P2y = P1y + dy; % Final point

    plot([0 X X 0 0],[0 0 Y Y 0]); hold on

    for j = 1:N
    plot(P1x(j),P1y(j),'ro')
    plot([P1x(j) P2x(j)],[P1y(j) P2y(j)],'-')
    end

    k=line([(X+Y)/2.25, (X+Y)/3, (X+Y)/3, (X+Y)/4] , [0, (X+Y)/10, (X+Y)/2.5, (X+Y)/2]);

    xlabel('X [km]'); ylabel('Y [km]');
    xlim([-X/4 1.25*X]); ylim([-Y/4 1.25*Y])



plot screenshot










share|improve this question
















  1. How can I make code in Matlab that calculates how many storm tracks pass the line, or how many do not pass, or how many overlap with each other (storm track and line)?


  2. How can I make code in Matlab that calculates the angle between the storm track and lines that are overlapped?
    I already tried but it’s not working.



    N = 50; % Number of events  
    X = 50; Y = 50;

    P1x = rand(N,1) * X;
    P1y = rand(N,1) * Y ; % initial point

    L = lognrnd(2,0.7,[N,1]); % Sample track length
    Theta = mod(normrnd(90,15,[N,1]),360);

    dx = L.*cos(deg2rad(Theta - 90));
    dy = L.*sin(deg2rad(Theta - 270));

    P2x = P1x + dx; P2y = P1y + dy; % Final point

    plot([0 X X 0 0],[0 0 Y Y 0]); hold on

    for j = 1:N
    plot(P1x(j),P1y(j),'ro')
    plot([P1x(j) P2x(j)],[P1y(j) P2y(j)],'-')
    end

    k=line([(X+Y)/2.25, (X+Y)/3, (X+Y)/3, (X+Y)/4] , [0, (X+Y)/10, (X+Y)/2.5, (X+Y)/2]);

    xlabel('X [km]'); ylabel('Y [km]');
    xlim([-X/4 1.25*X]); ylim([-Y/4 1.25*Y])



plot screenshot







matlab matlab-figure






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 at 0:38









Mihai Chelaru

2,14291022




2,14291022










asked Nov 16 at 0:05









Razib

11




11












  • There is no legend in your plot....why don't you tell us..what you want from figure? Is it the points (red circles) intersecting the blue box? Be clear. Specify what is a track and what is a line here?
    – Siva Srinivas Kolukula
    Nov 16 at 3:50










  • here, i already generate 50 storm track randomly. (if you run this code then you might be understand). red circles are the initial point of the storm track which is passes from left to right direction towards the blue line and blue line is the line structures (assumes). i need to know how many storm track will pass this blue line (that means line structures) how many not and also how many intersect? also if the storm track and line intersects each other then what is the angle between this two ? whole process has to be made through Matlab? i hope you will understand now @SivaSrinivas
    – Razib
    Nov 16 at 4:32


















  • There is no legend in your plot....why don't you tell us..what you want from figure? Is it the points (red circles) intersecting the blue box? Be clear. Specify what is a track and what is a line here?
    – Siva Srinivas Kolukula
    Nov 16 at 3:50










  • here, i already generate 50 storm track randomly. (if you run this code then you might be understand). red circles are the initial point of the storm track which is passes from left to right direction towards the blue line and blue line is the line structures (assumes). i need to know how many storm track will pass this blue line (that means line structures) how many not and also how many intersect? also if the storm track and line intersects each other then what is the angle between this two ? whole process has to be made through Matlab? i hope you will understand now @SivaSrinivas
    – Razib
    Nov 16 at 4:32
















There is no legend in your plot....why don't you tell us..what you want from figure? Is it the points (red circles) intersecting the blue box? Be clear. Specify what is a track and what is a line here?
– Siva Srinivas Kolukula
Nov 16 at 3:50




There is no legend in your plot....why don't you tell us..what you want from figure? Is it the points (red circles) intersecting the blue box? Be clear. Specify what is a track and what is a line here?
– Siva Srinivas Kolukula
Nov 16 at 3:50












here, i already generate 50 storm track randomly. (if you run this code then you might be understand). red circles are the initial point of the storm track which is passes from left to right direction towards the blue line and blue line is the line structures (assumes). i need to know how many storm track will pass this blue line (that means line structures) how many not and also how many intersect? also if the storm track and line intersects each other then what is the angle between this two ? whole process has to be made through Matlab? i hope you will understand now @SivaSrinivas
– Razib
Nov 16 at 4:32




here, i already generate 50 storm track randomly. (if you run this code then you might be understand). red circles are the initial point of the storm track which is passes from left to right direction towards the blue line and blue line is the line structures (assumes). i need to know how many storm track will pass this blue line (that means line structures) how many not and also how many intersect? also if the storm track and line intersects each other then what is the angle between this two ? whole process has to be made through Matlab? i hope you will understand now @SivaSrinivas
– Razib
Nov 16 at 4:32












2 Answers
2






active

oldest

votes


















1














You can use the function InterX to get the intersection point between the blue line and the storm line. Check the below code. I have made few changes at the plot of storm line, you need not to use a loop there. Once you have the intersection point, you can get the required angle using dot product or slope formula.



N = 50; % Number of events
X = 50; Y = 50;

P1x = rand(N,1) * X;
P1y = rand(N,1) * Y ; % initial point

L = lognrnd(2,0.7,[N,1]); % Sample track length
Theta = mod(normrnd(90,15,[N,1]),360);

dx = L.*cos(deg2rad(Theta - 90));
dy = L.*sin(deg2rad(Theta - 270));

P2x = P1x + dx; P2y = P1y + dy; % Final point

plot([0 X X 0 0],[0 0 Y Y 0]); hold on
% GEt the line
lx = [(X+Y)/2.25, (X+Y)/3, (X+Y)/3, (X+Y)/4] ;
ly = [0, (X+Y)/10, (X+Y)/2.5, (X+Y)/2];
plot(lx,ly,'b')

plot(P1x,P1y,'ro')
plot([P1x P2x]',[P1y P2y]','-')

% Get intersections
iwant = zeros(N,1) ; % this gives whether point intersects or not
for i = 1:N
L1 = [lx ; ly] ;
L2 = [P1x(i) P2x(i) ;P1y(i) P2y(i)] ;
P = InterX(L1,L2) ;
if ~isempty(P)
plot(P(1),P(2),'*r')
iwant(i) = 1 ;
end
end

xlabel('X [km]'); ylabel('Y [km]');
xlim([-X/4 1.25*X]); ylim([-Y/4 1.25*Y])


Check the figure/ result generated from the above code. The red starred points are your intersection points.



enter image description here






share|improve this answer





















  • thank you so much for your response. i will check it . if i face some problem again i will ask you ..thank you once again :)
    – Razib
    Nov 17 at 9:56










  • hi Siva Srinivas Kolukula, hope you are fine. i need some help again regarding MATLAB CODE. Now i want to make some foot print rectangle area around each of the storm track length. In details, each storm track length will be the central length of the rectangle. I need to make this code in previous code through Matlab. So would you please help me. I tried a lot but could not.
    – Razib
    Dec 3 at 5:15



















0














N = 50; % Number of events
X = 50; Y = 50;
P1x = rand(N,1) * X; P1y = rand(N,1) * Y ; % initial point
L = lognrnd(2,0.7,[N,1]); % Sample track length
Theta = mod(normrnd(90,15,[N,1]),360); % Storm track bearing direction
dx = L.*cos(deg2rad(Theta - 90)); dy = L.*sin(deg2rad(Theta - 270));
P2x = P1x + dx; P2y = P1y + dy; % Final point
plot([0 X X 0 0],[0 0 Y Y 0]); hold on
plot(P1x,P1y,'ro');
plot([P1x P2x]',[P1y P2y]','-')
xlabel('X [km]'); ylabel('Y [km]');
xlim([-X/4 1.25*X]); ylim([-Y/4 1.25*Y])
%% Draw rectangles
Vx = [P1x P2x]' ;
Vy = [P1y P2y]' ;
t = 1./2 ;
% Loop to get normals
for i = 1:size(Vx,2)
N=LineNormals2D([Vx(:,i) Vy(:,i)]') ;

C = [[Vx(:,i) Vy(:,i)]+t*N ;
[Vx(:,i) Vy(:,i)]-t*N] ;
idx = boundary(C(:,1),C(:,2)) ;
plot(C(idx,1),C(idx,2),'b')
end


Down the LineNormals2D function from the link: https://in.mathworks.com/matlabcentral/fileexchange/32696-2d-line-curvature-and-normals






share|improve this answer





















  • Many thanks !!.. I will check it and if i face some problem again i will ask you ..thank you once again.. :)
    – Razib
    Dec 4 at 5:30










  • I need your help again. with your help i already got randomly rectangle foot print area. But as you know there is also 1 blue line (please see attached image above). Now if the rectangle foot print intersect the blue line then how may i get the intersect point between rectangle foot print and line? Previously it was line to line intersect but now rectangle foot print to line intersect and i need to make some code and plot in matlab about this. For your kind notification you may check above the code file also @Siva Srinivas Kolukula .. many thanks and sorry to bother you.
    – Razib
    Dec 7 at 6:18












  • @ Siva Srinivas Kolukula i need your help. Please kindly help me if possible for you .thank you in advance and sorry to bother you.
    – Razib
    Dec 10 at 1:36











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53329585%2ftwo-questions-related-to-matlab-coding%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














You can use the function InterX to get the intersection point between the blue line and the storm line. Check the below code. I have made few changes at the plot of storm line, you need not to use a loop there. Once you have the intersection point, you can get the required angle using dot product or slope formula.



N = 50; % Number of events
X = 50; Y = 50;

P1x = rand(N,1) * X;
P1y = rand(N,1) * Y ; % initial point

L = lognrnd(2,0.7,[N,1]); % Sample track length
Theta = mod(normrnd(90,15,[N,1]),360);

dx = L.*cos(deg2rad(Theta - 90));
dy = L.*sin(deg2rad(Theta - 270));

P2x = P1x + dx; P2y = P1y + dy; % Final point

plot([0 X X 0 0],[0 0 Y Y 0]); hold on
% GEt the line
lx = [(X+Y)/2.25, (X+Y)/3, (X+Y)/3, (X+Y)/4] ;
ly = [0, (X+Y)/10, (X+Y)/2.5, (X+Y)/2];
plot(lx,ly,'b')

plot(P1x,P1y,'ro')
plot([P1x P2x]',[P1y P2y]','-')

% Get intersections
iwant = zeros(N,1) ; % this gives whether point intersects or not
for i = 1:N
L1 = [lx ; ly] ;
L2 = [P1x(i) P2x(i) ;P1y(i) P2y(i)] ;
P = InterX(L1,L2) ;
if ~isempty(P)
plot(P(1),P(2),'*r')
iwant(i) = 1 ;
end
end

xlabel('X [km]'); ylabel('Y [km]');
xlim([-X/4 1.25*X]); ylim([-Y/4 1.25*Y])


Check the figure/ result generated from the above code. The red starred points are your intersection points.



enter image description here






share|improve this answer





















  • thank you so much for your response. i will check it . if i face some problem again i will ask you ..thank you once again :)
    – Razib
    Nov 17 at 9:56










  • hi Siva Srinivas Kolukula, hope you are fine. i need some help again regarding MATLAB CODE. Now i want to make some foot print rectangle area around each of the storm track length. In details, each storm track length will be the central length of the rectangle. I need to make this code in previous code through Matlab. So would you please help me. I tried a lot but could not.
    – Razib
    Dec 3 at 5:15
















1














You can use the function InterX to get the intersection point between the blue line and the storm line. Check the below code. I have made few changes at the plot of storm line, you need not to use a loop there. Once you have the intersection point, you can get the required angle using dot product or slope formula.



N = 50; % Number of events
X = 50; Y = 50;

P1x = rand(N,1) * X;
P1y = rand(N,1) * Y ; % initial point

L = lognrnd(2,0.7,[N,1]); % Sample track length
Theta = mod(normrnd(90,15,[N,1]),360);

dx = L.*cos(deg2rad(Theta - 90));
dy = L.*sin(deg2rad(Theta - 270));

P2x = P1x + dx; P2y = P1y + dy; % Final point

plot([0 X X 0 0],[0 0 Y Y 0]); hold on
% GEt the line
lx = [(X+Y)/2.25, (X+Y)/3, (X+Y)/3, (X+Y)/4] ;
ly = [0, (X+Y)/10, (X+Y)/2.5, (X+Y)/2];
plot(lx,ly,'b')

plot(P1x,P1y,'ro')
plot([P1x P2x]',[P1y P2y]','-')

% Get intersections
iwant = zeros(N,1) ; % this gives whether point intersects or not
for i = 1:N
L1 = [lx ; ly] ;
L2 = [P1x(i) P2x(i) ;P1y(i) P2y(i)] ;
P = InterX(L1,L2) ;
if ~isempty(P)
plot(P(1),P(2),'*r')
iwant(i) = 1 ;
end
end

xlabel('X [km]'); ylabel('Y [km]');
xlim([-X/4 1.25*X]); ylim([-Y/4 1.25*Y])


Check the figure/ result generated from the above code. The red starred points are your intersection points.



enter image description here






share|improve this answer





















  • thank you so much for your response. i will check it . if i face some problem again i will ask you ..thank you once again :)
    – Razib
    Nov 17 at 9:56










  • hi Siva Srinivas Kolukula, hope you are fine. i need some help again regarding MATLAB CODE. Now i want to make some foot print rectangle area around each of the storm track length. In details, each storm track length will be the central length of the rectangle. I need to make this code in previous code through Matlab. So would you please help me. I tried a lot but could not.
    – Razib
    Dec 3 at 5:15














1












1








1






You can use the function InterX to get the intersection point between the blue line and the storm line. Check the below code. I have made few changes at the plot of storm line, you need not to use a loop there. Once you have the intersection point, you can get the required angle using dot product or slope formula.



N = 50; % Number of events
X = 50; Y = 50;

P1x = rand(N,1) * X;
P1y = rand(N,1) * Y ; % initial point

L = lognrnd(2,0.7,[N,1]); % Sample track length
Theta = mod(normrnd(90,15,[N,1]),360);

dx = L.*cos(deg2rad(Theta - 90));
dy = L.*sin(deg2rad(Theta - 270));

P2x = P1x + dx; P2y = P1y + dy; % Final point

plot([0 X X 0 0],[0 0 Y Y 0]); hold on
% GEt the line
lx = [(X+Y)/2.25, (X+Y)/3, (X+Y)/3, (X+Y)/4] ;
ly = [0, (X+Y)/10, (X+Y)/2.5, (X+Y)/2];
plot(lx,ly,'b')

plot(P1x,P1y,'ro')
plot([P1x P2x]',[P1y P2y]','-')

% Get intersections
iwant = zeros(N,1) ; % this gives whether point intersects or not
for i = 1:N
L1 = [lx ; ly] ;
L2 = [P1x(i) P2x(i) ;P1y(i) P2y(i)] ;
P = InterX(L1,L2) ;
if ~isempty(P)
plot(P(1),P(2),'*r')
iwant(i) = 1 ;
end
end

xlabel('X [km]'); ylabel('Y [km]');
xlim([-X/4 1.25*X]); ylim([-Y/4 1.25*Y])


Check the figure/ result generated from the above code. The red starred points are your intersection points.



enter image description here






share|improve this answer












You can use the function InterX to get the intersection point between the blue line and the storm line. Check the below code. I have made few changes at the plot of storm line, you need not to use a loop there. Once you have the intersection point, you can get the required angle using dot product or slope formula.



N = 50; % Number of events
X = 50; Y = 50;

P1x = rand(N,1) * X;
P1y = rand(N,1) * Y ; % initial point

L = lognrnd(2,0.7,[N,1]); % Sample track length
Theta = mod(normrnd(90,15,[N,1]),360);

dx = L.*cos(deg2rad(Theta - 90));
dy = L.*sin(deg2rad(Theta - 270));

P2x = P1x + dx; P2y = P1y + dy; % Final point

plot([0 X X 0 0],[0 0 Y Y 0]); hold on
% GEt the line
lx = [(X+Y)/2.25, (X+Y)/3, (X+Y)/3, (X+Y)/4] ;
ly = [0, (X+Y)/10, (X+Y)/2.5, (X+Y)/2];
plot(lx,ly,'b')

plot(P1x,P1y,'ro')
plot([P1x P2x]',[P1y P2y]','-')

% Get intersections
iwant = zeros(N,1) ; % this gives whether point intersects or not
for i = 1:N
L1 = [lx ; ly] ;
L2 = [P1x(i) P2x(i) ;P1y(i) P2y(i)] ;
P = InterX(L1,L2) ;
if ~isempty(P)
plot(P(1),P(2),'*r')
iwant(i) = 1 ;
end
end

xlabel('X [km]'); ylabel('Y [km]');
xlim([-X/4 1.25*X]); ylim([-Y/4 1.25*Y])


Check the figure/ result generated from the above code. The red starred points are your intersection points.



enter image description here







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 16 at 6:16









Siva Srinivas Kolukula

9401512




9401512












  • thank you so much for your response. i will check it . if i face some problem again i will ask you ..thank you once again :)
    – Razib
    Nov 17 at 9:56










  • hi Siva Srinivas Kolukula, hope you are fine. i need some help again regarding MATLAB CODE. Now i want to make some foot print rectangle area around each of the storm track length. In details, each storm track length will be the central length of the rectangle. I need to make this code in previous code through Matlab. So would you please help me. I tried a lot but could not.
    – Razib
    Dec 3 at 5:15


















  • thank you so much for your response. i will check it . if i face some problem again i will ask you ..thank you once again :)
    – Razib
    Nov 17 at 9:56










  • hi Siva Srinivas Kolukula, hope you are fine. i need some help again regarding MATLAB CODE. Now i want to make some foot print rectangle area around each of the storm track length. In details, each storm track length will be the central length of the rectangle. I need to make this code in previous code through Matlab. So would you please help me. I tried a lot but could not.
    – Razib
    Dec 3 at 5:15
















thank you so much for your response. i will check it . if i face some problem again i will ask you ..thank you once again :)
– Razib
Nov 17 at 9:56




thank you so much for your response. i will check it . if i face some problem again i will ask you ..thank you once again :)
– Razib
Nov 17 at 9:56












hi Siva Srinivas Kolukula, hope you are fine. i need some help again regarding MATLAB CODE. Now i want to make some foot print rectangle area around each of the storm track length. In details, each storm track length will be the central length of the rectangle. I need to make this code in previous code through Matlab. So would you please help me. I tried a lot but could not.
– Razib
Dec 3 at 5:15




hi Siva Srinivas Kolukula, hope you are fine. i need some help again regarding MATLAB CODE. Now i want to make some foot print rectangle area around each of the storm track length. In details, each storm track length will be the central length of the rectangle. I need to make this code in previous code through Matlab. So would you please help me. I tried a lot but could not.
– Razib
Dec 3 at 5:15













0














N = 50; % Number of events
X = 50; Y = 50;
P1x = rand(N,1) * X; P1y = rand(N,1) * Y ; % initial point
L = lognrnd(2,0.7,[N,1]); % Sample track length
Theta = mod(normrnd(90,15,[N,1]),360); % Storm track bearing direction
dx = L.*cos(deg2rad(Theta - 90)); dy = L.*sin(deg2rad(Theta - 270));
P2x = P1x + dx; P2y = P1y + dy; % Final point
plot([0 X X 0 0],[0 0 Y Y 0]); hold on
plot(P1x,P1y,'ro');
plot([P1x P2x]',[P1y P2y]','-')
xlabel('X [km]'); ylabel('Y [km]');
xlim([-X/4 1.25*X]); ylim([-Y/4 1.25*Y])
%% Draw rectangles
Vx = [P1x P2x]' ;
Vy = [P1y P2y]' ;
t = 1./2 ;
% Loop to get normals
for i = 1:size(Vx,2)
N=LineNormals2D([Vx(:,i) Vy(:,i)]') ;

C = [[Vx(:,i) Vy(:,i)]+t*N ;
[Vx(:,i) Vy(:,i)]-t*N] ;
idx = boundary(C(:,1),C(:,2)) ;
plot(C(idx,1),C(idx,2),'b')
end


Down the LineNormals2D function from the link: https://in.mathworks.com/matlabcentral/fileexchange/32696-2d-line-curvature-and-normals






share|improve this answer





















  • Many thanks !!.. I will check it and if i face some problem again i will ask you ..thank you once again.. :)
    – Razib
    Dec 4 at 5:30










  • I need your help again. with your help i already got randomly rectangle foot print area. But as you know there is also 1 blue line (please see attached image above). Now if the rectangle foot print intersect the blue line then how may i get the intersect point between rectangle foot print and line? Previously it was line to line intersect but now rectangle foot print to line intersect and i need to make some code and plot in matlab about this. For your kind notification you may check above the code file also @Siva Srinivas Kolukula .. many thanks and sorry to bother you.
    – Razib
    Dec 7 at 6:18












  • @ Siva Srinivas Kolukula i need your help. Please kindly help me if possible for you .thank you in advance and sorry to bother you.
    – Razib
    Dec 10 at 1:36
















0














N = 50; % Number of events
X = 50; Y = 50;
P1x = rand(N,1) * X; P1y = rand(N,1) * Y ; % initial point
L = lognrnd(2,0.7,[N,1]); % Sample track length
Theta = mod(normrnd(90,15,[N,1]),360); % Storm track bearing direction
dx = L.*cos(deg2rad(Theta - 90)); dy = L.*sin(deg2rad(Theta - 270));
P2x = P1x + dx; P2y = P1y + dy; % Final point
plot([0 X X 0 0],[0 0 Y Y 0]); hold on
plot(P1x,P1y,'ro');
plot([P1x P2x]',[P1y P2y]','-')
xlabel('X [km]'); ylabel('Y [km]');
xlim([-X/4 1.25*X]); ylim([-Y/4 1.25*Y])
%% Draw rectangles
Vx = [P1x P2x]' ;
Vy = [P1y P2y]' ;
t = 1./2 ;
% Loop to get normals
for i = 1:size(Vx,2)
N=LineNormals2D([Vx(:,i) Vy(:,i)]') ;

C = [[Vx(:,i) Vy(:,i)]+t*N ;
[Vx(:,i) Vy(:,i)]-t*N] ;
idx = boundary(C(:,1),C(:,2)) ;
plot(C(idx,1),C(idx,2),'b')
end


Down the LineNormals2D function from the link: https://in.mathworks.com/matlabcentral/fileexchange/32696-2d-line-curvature-and-normals






share|improve this answer





















  • Many thanks !!.. I will check it and if i face some problem again i will ask you ..thank you once again.. :)
    – Razib
    Dec 4 at 5:30










  • I need your help again. with your help i already got randomly rectangle foot print area. But as you know there is also 1 blue line (please see attached image above). Now if the rectangle foot print intersect the blue line then how may i get the intersect point between rectangle foot print and line? Previously it was line to line intersect but now rectangle foot print to line intersect and i need to make some code and plot in matlab about this. For your kind notification you may check above the code file also @Siva Srinivas Kolukula .. many thanks and sorry to bother you.
    – Razib
    Dec 7 at 6:18












  • @ Siva Srinivas Kolukula i need your help. Please kindly help me if possible for you .thank you in advance and sorry to bother you.
    – Razib
    Dec 10 at 1:36














0












0








0






N = 50; % Number of events
X = 50; Y = 50;
P1x = rand(N,1) * X; P1y = rand(N,1) * Y ; % initial point
L = lognrnd(2,0.7,[N,1]); % Sample track length
Theta = mod(normrnd(90,15,[N,1]),360); % Storm track bearing direction
dx = L.*cos(deg2rad(Theta - 90)); dy = L.*sin(deg2rad(Theta - 270));
P2x = P1x + dx; P2y = P1y + dy; % Final point
plot([0 X X 0 0],[0 0 Y Y 0]); hold on
plot(P1x,P1y,'ro');
plot([P1x P2x]',[P1y P2y]','-')
xlabel('X [km]'); ylabel('Y [km]');
xlim([-X/4 1.25*X]); ylim([-Y/4 1.25*Y])
%% Draw rectangles
Vx = [P1x P2x]' ;
Vy = [P1y P2y]' ;
t = 1./2 ;
% Loop to get normals
for i = 1:size(Vx,2)
N=LineNormals2D([Vx(:,i) Vy(:,i)]') ;

C = [[Vx(:,i) Vy(:,i)]+t*N ;
[Vx(:,i) Vy(:,i)]-t*N] ;
idx = boundary(C(:,1),C(:,2)) ;
plot(C(idx,1),C(idx,2),'b')
end


Down the LineNormals2D function from the link: https://in.mathworks.com/matlabcentral/fileexchange/32696-2d-line-curvature-and-normals






share|improve this answer












N = 50; % Number of events
X = 50; Y = 50;
P1x = rand(N,1) * X; P1y = rand(N,1) * Y ; % initial point
L = lognrnd(2,0.7,[N,1]); % Sample track length
Theta = mod(normrnd(90,15,[N,1]),360); % Storm track bearing direction
dx = L.*cos(deg2rad(Theta - 90)); dy = L.*sin(deg2rad(Theta - 270));
P2x = P1x + dx; P2y = P1y + dy; % Final point
plot([0 X X 0 0],[0 0 Y Y 0]); hold on
plot(P1x,P1y,'ro');
plot([P1x P2x]',[P1y P2y]','-')
xlabel('X [km]'); ylabel('Y [km]');
xlim([-X/4 1.25*X]); ylim([-Y/4 1.25*Y])
%% Draw rectangles
Vx = [P1x P2x]' ;
Vy = [P1y P2y]' ;
t = 1./2 ;
% Loop to get normals
for i = 1:size(Vx,2)
N=LineNormals2D([Vx(:,i) Vy(:,i)]') ;

C = [[Vx(:,i) Vy(:,i)]+t*N ;
[Vx(:,i) Vy(:,i)]-t*N] ;
idx = boundary(C(:,1),C(:,2)) ;
plot(C(idx,1),C(idx,2),'b')
end


Down the LineNormals2D function from the link: https://in.mathworks.com/matlabcentral/fileexchange/32696-2d-line-curvature-and-normals







share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 4 at 4:21









Siva Srinivas Kolukula

9401512




9401512












  • Many thanks !!.. I will check it and if i face some problem again i will ask you ..thank you once again.. :)
    – Razib
    Dec 4 at 5:30










  • I need your help again. with your help i already got randomly rectangle foot print area. But as you know there is also 1 blue line (please see attached image above). Now if the rectangle foot print intersect the blue line then how may i get the intersect point between rectangle foot print and line? Previously it was line to line intersect but now rectangle foot print to line intersect and i need to make some code and plot in matlab about this. For your kind notification you may check above the code file also @Siva Srinivas Kolukula .. many thanks and sorry to bother you.
    – Razib
    Dec 7 at 6:18












  • @ Siva Srinivas Kolukula i need your help. Please kindly help me if possible for you .thank you in advance and sorry to bother you.
    – Razib
    Dec 10 at 1:36


















  • Many thanks !!.. I will check it and if i face some problem again i will ask you ..thank you once again.. :)
    – Razib
    Dec 4 at 5:30










  • I need your help again. with your help i already got randomly rectangle foot print area. But as you know there is also 1 blue line (please see attached image above). Now if the rectangle foot print intersect the blue line then how may i get the intersect point between rectangle foot print and line? Previously it was line to line intersect but now rectangle foot print to line intersect and i need to make some code and plot in matlab about this. For your kind notification you may check above the code file also @Siva Srinivas Kolukula .. many thanks and sorry to bother you.
    – Razib
    Dec 7 at 6:18












  • @ Siva Srinivas Kolukula i need your help. Please kindly help me if possible for you .thank you in advance and sorry to bother you.
    – Razib
    Dec 10 at 1:36
















Many thanks !!.. I will check it and if i face some problem again i will ask you ..thank you once again.. :)
– Razib
Dec 4 at 5:30




Many thanks !!.. I will check it and if i face some problem again i will ask you ..thank you once again.. :)
– Razib
Dec 4 at 5:30












I need your help again. with your help i already got randomly rectangle foot print area. But as you know there is also 1 blue line (please see attached image above). Now if the rectangle foot print intersect the blue line then how may i get the intersect point between rectangle foot print and line? Previously it was line to line intersect but now rectangle foot print to line intersect and i need to make some code and plot in matlab about this. For your kind notification you may check above the code file also @Siva Srinivas Kolukula .. many thanks and sorry to bother you.
– Razib
Dec 7 at 6:18






I need your help again. with your help i already got randomly rectangle foot print area. But as you know there is also 1 blue line (please see attached image above). Now if the rectangle foot print intersect the blue line then how may i get the intersect point between rectangle foot print and line? Previously it was line to line intersect but now rectangle foot print to line intersect and i need to make some code and plot in matlab about this. For your kind notification you may check above the code file also @Siva Srinivas Kolukula .. many thanks and sorry to bother you.
– Razib
Dec 7 at 6:18














@ Siva Srinivas Kolukula i need your help. Please kindly help me if possible for you .thank you in advance and sorry to bother you.
– Razib
Dec 10 at 1:36




@ Siva Srinivas Kolukula i need your help. Please kindly help me if possible for you .thank you in advance and sorry to bother you.
– Razib
Dec 10 at 1:36


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53329585%2ftwo-questions-related-to-matlab-coding%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents