Draw a square with one line?

Hello,
Is it possible to draw a square with one line?
What I mean is I got a line that I know, lets say x=[0,0], y=[0,1]; and I want to make a square with that line. In real life if I want a square I need only one line and I will make it because I know other lines are the same length.
The thing I am looking for is that I got a different X and Y data. I mean I got an exponential line so when the Y=1 my X is (lets say) 0.2412.
So I want to know when my Y= 2 what will be my X? DON'T FORGET THAT LINE IS EXPONENTIAL so if Y=1 and X=0.2412 then Y=2 is NOT X=2*(0.2412)
Thats why I want to make a square and guess the X data when I know the Y.
On the picture below is my problem. I want to know what is the X value when my Y is known ( the "+" on 0.025X).
The line from y=0 to y="+" is have to fall down and the tip of the line is my X searching value!!!!
THANK YOU A LOT!

5 Comments

A square has 4 sides, so it needs 4 straight lines. These 4 lines can be made with a single call to the line() function if you pass in the right vertex locations. But you seem to have a unique definition of line. For example, an exponential function is curved - it's a curve, not a line. Your diagram did not help. The point (0.2412, 1) does not even appear on your diagram, where the largest x is 0.0400. I also did not understand the English of this at all: "The line from y=0 to y="+" is have to fall down and the tip of the line is my X searching value!!!!" Finally, why do you have 4 differently colored curves?
The line from y=0 to y="+" is have to fall down and the tip of the line is my X searching value!!!!"
That was example.Sorry for my english and iam newbie in matlab.
i need to find the point 1 value in the picture below. and here is my code!
clc;
clear;
format shortg
f=50;%chestota f
w=2*pi*f;%aglova chestota
t=[0:0.00001:20e-3];%vremeto
w1=156;%broi navivki
Tokm=[0,5.426E-02,8.061E-02,1.047E-01,1.305E-01,1.610E-01,1.975E-01,2.409E-01,...
3.025E-01,3.932E-01,5.299E-01,7.267E-01,8.367E-01,8.966E-01,9.913E-01];
Potokm=[0,5.887E-04,1.148E-03,1.737E-03,2.314E-03,2.894E-03,3.472E-03,4.049E-03,...
4.632E-03,5.200E-03,5.777E-03,6.360E-03,6.651E-03,6.774E-03,6.937E-03];
Potokm1=Potokm./Potokm(13);%privejdane v o.e. Ф/Фн
Tokm1=Tokm./Tokm(13);%privejdane v o.e. I/I0н
ImiuRm=[0,5.426E-02,8.061E-02,1.047E-01,1.305E-01,1.610E-01,1.975E-01,2.409E-01,3.025E-01...
,3.932E-01,5.299E-01,7.267E-01,8.367E-01,8.966E-01,9.913E-01,9.913E-01,8.966E-01,8.367E-01,...
7.267E-01,5.299E-01,3.932E-01,3.025E-01,2.409E-01,1.975E-01,1.610E-01,1.305E-01,1.047E-01,...
8.061E-02,5.426E-02,0];
ImiuRm1=ImiuRm./ImiuRm(13);%privejdane v o.e. I/I0н
time=[0:0.357142857142857142e-3:5e-3,5e-3:0.357142857142857142e-3:10e-3];
%time2=[0:7.142857142e-4:0.01];
figure(1)
%plot(time,ImiuR)
n = 13 ; % can be changed
p = polyfit(time,ImiuRm1,n);
x = linspace(min(time),max(time));
y = polyval(p,x);
%hold on
plot(y,x);grid on
Fi=Potokm1(15)*sin(w*t+0);
x=x-(10e-3/(180/27.861));
clf;
plot(x,y,t,Fi);
hold on
plot(x+10e-3,y*-1);%dava mi otricatelniq polu period
Tokm2=(Tokm1/100)+0.025;
hold on
%plot(x,y,t,Fi,Tokm2,Potokm1)
%xlabel('Времето wt')
%ylabel('Фm, o.e и i0m, o.e')
%title('Пренесен ток ')
%legend('Ток i0m','Поток Фm','Основна крива')
plot(Tokm2,Potokm1)
grid on
[xi,yi] = polyxpoly([0 0],[0 5],x,y);%kudeto toka presicha ordinatnata os
mapshow(xi,yi,'DisplayType','point','Marker','*')
purvo=Potokm1(13)/yi %vtori nachin za namirane na Hc
vtoro=Tokm1(13)/purvo
Iccc=(((vtoro-0.025))*Tokm(13))
Icencen=((vtoro/100)+0.025)-(vtoro/100)
[xii,yii] = polyxpoly([xi 50],[yi yi],[Tokm2(1),Tokm2(13)],[Potokm1(1),Potokm1(13)]);%na kolko e raven toka(Hc), koito e xii
%mapshow(xii,yii,'DisplayType','point','Marker','o')
mapshow(Icencen,yii,'DisplayType','point','Marker','+')
[xi2,yi2] = polyxpoly([x(100) x(100)],[0 5],t,Fi);%kudeto presicha vurho potoka
mapshow(xi2,yi2,'DisplayType','point','Marker','*')
[xii2,yii2] = polyxpoly([xi2 50],[yi2 yi2],Tokm2,Potokm1);%na kolko e raven toka(Br), koito e yii2
mapshow(xii2,yii2,'DisplayType','point','Marker','*')
%viscircles([Tokm2(1),Potokm1(1)],yi,'EdgeColor','b','linewidth',0.5);
hold on
%line([Tokm2(1),Tokm2(13)],[Potokm1(1),Potokm1(13)])
%line([xi 0.035],[yi yi])
Ic=(((xii-0.025))*100*Tokm(13))
Ic_oe=((xii-0.025))*100
lqdro=0.205;%daljina na qdroto
Sa=0.08^2;
Hc_m=((Ic*w1)/lqdro);
Br_m=(yii2*Potokm(13))/Sa;
Fr_m=(yii2*Potokm(13));
Fr_m2=yii2;
Bm=[0,0.092,0.179,0.271,0.362,0.452,0.543,0.633,0.724,0.812,0.903,0.994,1.039,1.058,1.084];
Hm=[0,41.29,61.34,79.64,99.30,122.51,150.27,183.31,230.23,299.25,403.25,552.98,636.74,682.30,754.33];
Hm_minus=-1*Hm;
Bm_minus=-1*Bm;
Tokm1_minus=Tokm1*-1;
Potokm1_minus=Potokm1*-1;
figure(2)
clf;
plot(Hm,Bm,Hm_minus,Bm_minus);
%mapshow(0,Br_m,'DisplayType','point','Marker','*')
%mapshow(Hc_m,0,'DisplayType','point','Marker','o')
reset(gca)
xlabel('i0m, o.e')
ylabel('Фm, o.e')
title('Основна намагнитваща крива')
grid on
You have several points labeled 1 - 4 I think.
  1. The lower left one looks like it's at (0,0) - the origin.
  2. The upper left one looks like it's where one of the curves intersects the y axis.
  3. I have no idea exactly where the point on the upper right 1 is at.
  4. Not sure where the lower right 1 is at. Is it where the curve crosses the y=0 line?
Krasimir Terziev
Krasimir Terziev on 18 Jun 2020
Edited: Krasimir Terziev on 18 Jun 2020
i hope this picture will explane you what i mean.
i know the Y+ value and i need to know the X+ value but the X and Y value have bigger difference( i mean Potokm1 from code above - the Y values are bigger then - Tokm3 values)
I thing this will help us to see where the points comes from.
i really appreciate ur help!

Sign in to comment.

Answers (1)

Not sure I have understood your problem. I think you want to find out x by drawing an orthogonal line from the y-axis, but I do not understand why because you seem to have the x data and the exponential function already.
I will try to answer to 2 possible problems
1.
You know your exponential function, then you can calculate x.
Let's say your exponential function is y = 4^x. Let's say y is 50.
(got this example here) Citing:
With the above information, you're ready to try solving for an exponent in an equation.
If you take the log to the base 10 of each side and omit explicit identification of the base, this becomes log 50 = log 4x.
log 50 = x log 4, or x = (log 50)/(log 4).
2.
You don't know your exponential function, but if you have plotted the result, you must have the x and y data somewhere.
So you can find it by indexing into the vectors that you plotted with. Let's again say you want the x value where y is 50.
plot(x, y);
y_index = find(y==50); % find the index in the ydata where y is 50
x_value = x(y_index); % index into the xdata

2 Comments

ok, will show you with a figure what i cant find.
On the picture down below i need to find the value of POINT ONE (p.1).
i just need somethink like circle with radius of one but my X value is smaller the my Y so if i write radius 1 THE circle became a Ellipse and i cant do notfing.
Just like a vector with the length of y=point 1 to fall down and how me the value of X.
THANGS FOR HELPING ME !
I am sorry, I cannot help you with this!

Sign in to comment.

Categories

Asked:

on 18 Jun 2020

Commented:

on 18 Jun 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!