Boundary conditions for different areas of phi

4 Ansichten (letzte 30 Tage)
Dave K.
Dave K. am 29 Jun. 2020
Kommentiert: Dave K. am 29 Jun. 2020
Dear Forum,
This is my first post, I hope I'm not doing anything wrong. I am not a native English speaker, but I hope to translate the mathematical expressions well.
I want to define a function for a cam gear. I have already defined the cam mechanism linearly, now I want to define the actual function using a sinoid. That means, I set up the laws of motion in general. I have done that (f0,f1,f2,f1f2). Now I would like to determine the special parameters and for this I define the motion function and its derivatives (F0,F1,F2,F1F2) again with boundary conditions. For example, for phi between 0° and 10° the motion function of the path should be -1.
I wanted to try it the way you can see below. But no matter what I do, the error remains. I need your help.
N_Vert = 25.4/11; %11 needles for 25.4mm = 2.31mm
% define Positions
s_hubweg = N_Vert*[0;-1;-1;0;0;1;1;2;2;1;1;0;0];
winkel = [0;10;22.5;32.5;45;55;90;100;112.5;122.5;135;145;180];
% create the laws of movement
z = linspace(0,1,180);
f0 = 0.5*(1-cos(pi*z)); %added for the forum: f0=f
f1 = (pi/2)*sin(pi*z); %added for the forum: f1=f'
f2 = (pi^2/2)*cos(pi*z); %added for the forum: f2=f''
f1f2 = f1.*f2; %added for the forum: f1f2=f'*f''
% nominal parameters for cam gear
C_vn = 1.57;
C_an = 4.93;
C_Mdynn = 3.88;
% Übertragungsfunktion F von phi
phi = linspace(0,360,360);
% define Function for areas of phi
% function of the way
F0(phi>=0 & phi<10) = flip(f0-1);
F0(phi>=10 & phi<22.5) = -1;
F0(phi>=22.5 & phi<32.5) = f0-1;
% ... and more
% function of speed
F1(phi>=0 & phi<10) = -f1;
F1(phi>=10 & phi<22.5) = 0;
F1(phi>=22.5 & phi<32.5) = f1;
% ... and more
% function of acceleration
F2(phi>=0 & phi<10) = -f2;
F2(phi>=10 & phi<22.5) = 0;
F2(phi>=22.5 & phi<32.5) = f2;
% ... and more
% function of momentum
F1F2(phi>=0 & phi<10) = -f1f2;
F1F2(phi>=10 & phi<22.5) = 0;
F1F2(phi>=22.5 & phi<32.5) = f1f2;
% ... and more
% adjust amplitudes
F0 = F0*N_Vert;
F1 = F1*N_Vert;
F2 = F2*N_Vert;
F1F2 = F1F2*N_Vert.^2;
My error starts to appear with this line:
F0(phi>=0 & phi<10) = flip(f0-1);
And continues with all similar lines.
I hope I've given you all the relevant information about the code so that you can understand my problem.
Can you tell me, how to setup such a process correctly in MATLAB?
I would be very grateful for an answer! Thanks a lot!

Akzeptierte Antwort

Alan Stevens
Alan Stevens am 29 Jun. 2020
Bearbeitet: Alan Stevens am 29 Jun. 2020
Firstly, phi is size 1x360, whereas f0 is of size 1x180, but, more importantly perhaps, phi>=0 & phi<10 means you want elements that are both less than and greater than zero!. I suspect you meant phi>=0 | phi<10 (or, rather than and). The result of phi>=0 & phi<10 is to return a vector of zeros, and MATLAB indexing starts at 1 not 0.
  7 Kommentare
Dave K.
Dave K. am 29 Jun. 2020
Bearbeitet: Dave K. am 29 Jun. 2020
I will try that in a few minutes! (...I have about 24 lines for every F_i and in total 4 functions, so it seems like I have to use about 96 temp values and that will take its time)
Thank you very much!
Dave K.
Dave K. am 29 Jun. 2020
Unfortunately this solution didn't work either. I now proceeded to create the function manually:
z = linspace(0,1,20);
f0 = 0.5*(1-cos(pi*z));
F0_1 = flip(f0-1);
F0_2 = -1*ones(1,25);
F0_3 = f0-1;
F0_4 = 0*ones(1,25);
F0_5 = f0;
F0_6 = 1*ones(1,70);
F0_7 = f0+1;
F0_8 = 2*ones(1,25);
F0_9 = flip(f0+1);
F0_10 = 1*ones(1,25);
F0_11 = flip(f0);
F0_12 = 0*ones(1,70);
F0_13 = flip(f0-1);
F0_14 = -1*ones(1,25);
F0_15 = f0-1;
F0_16 = 0*ones(1,25);
F0_17 = f0;
F0_18 = 1*ones(1,70);
F0_19 = f0+1;
F0_20 = 2*ones(1,25);
F0_21 = flip(f0+1);
F0_22 = 1*ones(1,25);
F0_23 = flip(f0);
F0_24 = 0*ones(1,70);
F0_T1 = [F0_1 F0_2 F0_3 F0_4 F0_5 F0_6 F0_7 F0_8 F0_9 F0_10 F0_11 F0_12];
F0_T2 = [F0_13 F0_14 F0_15 F0_16 F0_17 F0_18 F0_19 F0_20 F0_21 F0_22];
F0_T3 = [F0_23 F0_24];
F0 = [F0_T1 F0_T2 F0_T3];
I chose z as 20, because this way I can get the .5° values. So 20=10°in0.5° steps. This solves it. ^^
Thank you very much anyway!!!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by