Advertisement
Guest User

for Ivan (sky lab)

a guest
Dec 7th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scilab 4.32 KB | None | 0 0
  1. T1 = 3;
  2. T2 = 3;
  3. T3 = 3;
  4. K = 5;
  5.  
  6. function clear_graph()
  7.     w = 0:0.01:5
  8.     Re = K * (w ^ 2 * (T1 * T2 + T2 * T3 + T3 * T1) - 1) ./ -((T1 ^ 2 * w ^ 2 + 1) .* (T2 ^ 2 * w ^ 2 + 1) .* (T3 ^ 2 * w ^ 2 + 1))
  9.     Im = K * (w .* (T1 + T2 + T3 - T1 * T2 * T3 * w ^ 2)) ./ -((T1 ^ 2 * w ^ 2 + 1) .* (T2 ^ 2 * w ^ 2 + 1) .* (T3 ^ 2 * w ^ 2 + 1))
  10.  
  11.     Ylah = 20 * log10(K / ((T1 * %i * w + 1) .* (T3 * %i * w + 1) .* (T2 * %i * w + 1)))
  12.     Xlah = log10(w)
  13.     subplot(221);
  14.     plot(Re, Im, 'white');
  15.     subplot(223);
  16.     plot(Xlah, Ylah, 'white');
  17. endfunction
  18.  
  19. function draw_graph()
  20.     w = 0:0.01:5
  21.     Re = K * (w ^ 2 * (T1 * T2 + T2 * T3 + T3 * T1) - 1) ./ -((T1 ^ 2 * w ^ 2 + 1) .* (T2 ^ 2 * w ^ 2 + 1) .* (T3 ^ 2 * w ^ 2 + 1))
  22.     Im = K * (w .* (T1 + T2 + T3 - T1 * T2 * T3 * w ^ 2)) ./ -((T1 ^ 2 * w ^ 2 + 1) .* (T2 ^ 2 * w ^ 2 + 1) .* (T3 ^ 2 * w ^ 2 + 1))
  23.  
  24.     Ylah = 20 * log10(K / ((T1 * %i * w + 1) .* (T3 * %i * w + 1) .* (T2 * %i * w + 1)))
  25.     Xlah = log10(w)
  26.     subplot(221);
  27.     plot(Re, Im, 'blue');
  28.     subplot(223);
  29.     plot(Xlah, Ylah, 'blue');
  30. endfunction
  31.  
  32.  
  33. //Создание окна
  34. f = figure();
  35. f.figure_position = [0, 0];
  36. f.background = color('white');
  37. f.figure_size = [1280, 960];
  38.  
  39. axes1 = newaxes();
  40. axes1.axes_bounds = [0,0,0.4,0.4];
  41. axes1.background = color(255,255,255);
  42. axes1.auto_clear = "on";
  43.  
  44. axes2 = newaxes();
  45. axes2.axes_bounds = [0,0.6,0.4,0.4];
  46. axes2.background = color(255,255,255);
  47. axes2.auto_clear = "on";  
  48.  
  49.  
  50.  
  51. //Создание объекта Slider для ввода T3
  52. slider1 = uicontrol(f, 'style', 'slider', 'Position', [1000 160 200 20], 'Min', 0.5, 'Max', 5, 'Value', T3, 'SliderStep', [0.1, 0.1]);
  53. slider1.Callback = 'clear_graph(); t3.string = string(round(slider1.Value * 10) / 10); s1v.string = string(round(slider1.Value * 10) / 10); T3 = round(slider1.Value * 10) / 10; draw_graph();';
  54. //Создание трех объектов Text для отображения текущего, min и max значений для слайдера
  55. s1v = uicontrol(f, 'style', 'text', 'Position', [1090 140 30 20], 'String', string(slider1.Value));
  56. s1min = uicontrol(f, 'style', 'text', 'Position', [1000 180 20 20], 'String', string(slider1.Min));
  57. s1max = uicontrol(f, 'style', 'text', 'Position', [1180 180 20 20], 'String', string(slider1.Max));
  58. uicontrol(f, "style", "text", 'Position', [1090 180 20 20], 'String', "  T3");
  59.  
  60. //Создание объекта Slider для ввода slider2
  61. slider2 = uicontrol(f, 'style', 'slider', 'Position', [1000 60 200 20], 'Min', 0.5, 'Max', 5, 'Value', T1, 'SliderStep', [0.1, 0.1]);
  62. slider2.Callback = 'clear_graph(); t1.string = string(round(slider2.Value * 10) / 10); s2v.string = string(round(slider2.Value * 10) / 10); T1 = round(slider2.Value * 10) / 10; draw_graph();';
  63. //Создание трех объектов Text для отображения текущего, min и max значений для слайдера
  64. s2v = uicontrol(f, 'style', 'text', 'Position', [1090 40 30 20], 'String', string(slider2.Value));
  65. s2min = uicontrol(f, 'style', 'text', 'Position', [1000 80 20 20], 'String', string(slider2.Min));
  66. s2max = uicontrol(f, 'style', 'text', 'Position', [1180 80 20 20], 'String', string(slider2.Max));
  67. uicontrol(f, "style", "text", 'Position', [1090 80 20 20], 'String', "  T1");
  68.  
  69. //Создание объекта Edit для ввода значения T3
  70. t3 = uicontrol(f, 'style', 'edit', 'Position', [1090 715 35 30], 'FontSize', 20, 'String', string(slider1.Value), 'Callback', 'clear_graph(); s1v.string = t3.String; slider1.value = evstr(t3.String); T3 = round(slider1.Value * 10) / 10; draw_graph();');
  71.  
  72.  
  73. //Создание объекта Edit для ввода значения T1
  74. t1 = uicontrol(f, 'style', 'edit', 'Position', [816 715 35 30], 'FontSize', 20, 'String', string(slider2.Value), 'Callback', 'clear_graph(); s2v.string = t1.String; slider2.value = evstr(t1.String); T1 = round(slider1.Value * 10) / 10; draw_graph();');
  75.  
  76.  
  77. //Создание объекта Edit для ввода значения K
  78. k = uicontrol(f, 'style', 'edit', 'Position', [980 761 60 30], 'FontSize', 20, 'String', string(K), 'Callback', 'clear_graph(); K = round((evstr(k.String)) * 10) / 10; draw_graph();');
  79.  
  80.  
  81. xstring(1.6,2.63,'$W(p)=\frac K {(\;\;\;\;p+1)(T_2p+1)(\;\;\;\;p+1)}$',0,1)
  82. gce().font_size = 6
  83. draw_graph()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement