# How to get an y-value (y1(x)) for the sub condition of 0.8y1=0.25x

2 views (last 30 days)
Alexander Busch on 29 Jul 2019
Commented: Alexander Busch on 5 Aug 2019
Hi there,
i need some help. I have two collum vectors y=force and x=settlement. Now i had to write a scribt which gives me the first y-value (y1(x)) where the subcondition: 0.8*y1=0.25x is true. I am not so familar whith loops and so I would need some help.
Thank you!

Show 1 older comment
Alexander Busch on 30 Jul 2019
The actual try is this one. Dont know if it makes sense. Even "zero" is not working at the moment (Undefined function 'zero' for input arguments of type 'double'.)
x=zero(lenght(settlement),1);
for
i=1+1:force(end);
x(i)=settlement(find(0.8*force(i)))/settlement(find(force(i)));
end
I=min(abs(x-0.25));
end
madhan ravi on 30 Jul 2019
zeros() not zero()
Alexander Busch on 30 Jul 2019
sry...
now it is this problem:
>> x=zeros(length(weg_fit_mm),1);
for
i=1+1:kraft_fit_kN(end);
x(i)=weg_fit_mm(find(0.8*kraft_fit_kN(i)))/weg_fit_mm(find(kraft_fit_kN(i)));
end
I=min(abs(x-0.25));
end
for
Error: Invalid expression. Check for missing or extra characters.

Vimal Rathod on 2 Aug 2019
In the code from the above comments, there is a problem with defining the for loop condition as the error was shown.
The 'i' variable should be defined in the same line as the for. And the value should not have a semicolon(;) at the end.
Here is a sample in the code which you could try.
for i=1:kraft_fit_kN(end)
You could refer to the following documentation for further details;

#### 1 Comment

Alexander Busch on 5 Aug 2019
Thank You!
It is working now