Thông báo

Collapse
No announcement yet.

[Trao đổi] Giải thích các hàm trong Matlab

Collapse
X
 
  • Lọc
  • Giờ
  • Show
Clear All
new posts

  • #16
    Các bác ơi cho em hỏi với..
    Bây h em muốn có 1 hàm gọi ảnh
    Tức là chuơng trình của em yêu cầu xử lý 1 bức ảnh, em muốn có hàm gọi ảnh để các bước sau phải viết câu lệnh đọc ảnh thêm lần nữa
    và có thể đọc đựoc nhiều ảnh mà k phải sửa code..
    Ai biết thì chỉ e với ạ

    Comment


    • #17
      ai pro hướng dẫn giúp e chỗ nào sai tí dc ko mọi ng

      Nguyên văn bởi thphong91 Xem bài viết
      Các bác ơi cho em hỏi với..
      Bây h em muốn có 1 hàm gọi ảnh
      Tức là chuơng trình của em yêu cầu xử lý 1 bức ảnh, em muốn có hàm gọi ảnh để các bước sau phải viết câu lệnh đọc ảnh thêm lần nữa
      và có thể đọc đựoc nhiều ảnh mà k phải sửa code..
      Ai biết thì chỉ e với ạ
      pd = 0.9; % Probability of detection
      pfa = 1e-6; % Probability of false alarm
      max_range = 5000; % Maximum unambiguous range
      range_res = 50; % Required range resolution
      tgt_rcs = 1; % Required target radar cross section
      prop_speed = physconst('LightSpeed'); % Propagation speed
      pulse_bw = prop_speed/(2*range_res); % Pulse bandwidth
      pulse_width = 1/pulse_bw; % Pulse width
      prf = prop_speed/(2*max_range); % Pulse repetition frequency
      fs = 2*pulse_bw; % Sampling rate
      hwav = phased.RectangularWaveform(...
      'PulseWidth',1/pulse_bw,...
      'PRF',prf,...
      'SampleRate',fs);
      noise_bw = pulse_bw;

      hrx = phased.ReceiverPreamp(...
      'Gain',20,...
      'NoiseBandwidth',noise_bw,...
      'NoiseFigure',0,...
      'SampleRate',fs,...
      'EnableInputPort',true);
      snr_db = [-inf, 0, 3, 10, 13];
      rocsnr(snr_db,'SignalType','NonfluctuatingNoncoher ent');
      num_pulse_int = 10;
      rocsnr([0 3 5],'SignalType','NonfluctuatingNoncoherent',...
      'NumPulses',num_pulse_int);
      snr_min = albersheim(pd, pfa, num_pulse_int)
      tx_gain = 20;

      fc = 10e9;
      lambda = prop_speed/fc;

      peak_power = radareqpow(lambda,max_range,snr_min,pulse_width,.. .
      'RCS',tgt_rcs,'Gain',tx_gain)
      htx = phased.Transmitter(...
      'Gain',tx_gain,...
      'PeakPower',peak_power,...
      'InUseOutputPort',true);
      hant = phased.IsotropicAntennaElement(...
      'FrequencyRange',[5e9 15e9]);

      hantplatform = phased.Platform(...
      'InitialPosition',[0; 0; 0],...
      'Velocity',[0; 0; 0]);
      hradiator = phased.Radiator(...
      'Sensor',hant,...
      'OperatingFrequency',fc);

      hcollector = phased.Collector(...
      'Sensor',hant,...
      'OperatingFrequency',fc);
      htarget{1} = phased.RadarTarget(...
      'MeanRCS',1.6,...
      'OperatingFrequency',fc);
      htargetplatform{1} = phased.Platform(...
      'InitialPosition',[2000.66; 0; 0]);

      htarget{2} = phased.RadarTarget(...
      'MeanRCS',2.2,...
      'OperatingFrequency',fc);
      htargetplatform{2} = phased.Platform(...
      'InitialPosition',[3532.63; 0; 0]);

      htarget{3} = phased.RadarTarget(...
      'MeanRCS',1.05,...
      'OperatingFrequency',fc);
      htargetplatform{3} = phased.Platform(...
      'InitialPosition',[3845.04; 0; 0]);
      htargetchannel{1} = phased.FreeSpace(...
      'SampleRate',fs,...
      'TwoWayPropagation',true,...
      'OperatingFrequency',fc);

      htargetchannel{2} = phased.FreeSpace(...
      'SampleRate',fs,...
      'TwoWayPropagation',true,...
      'OperatingFrequency',fc);

      htargetchannel{3} = phased.FreeSpace(...
      'SampleRate',fs,...
      'TwoWayPropagation',true,...
      'OperatingFrequency',fc);
      fast_time_grid = unigrid(0,1/fs,1/prf,'[)');
      slow_time_grid = (0:num_pulse_int-1)/prf;
      hrx.SeedSource = 'Property';
      hrx.Seed = 2007;

      rx_pulses = zeros(numel(fast_time_grid),num_pulse_int); % pre-allocate

      for m = 1:num_pulse_int
      [ant_pos,ant_vel] = step(hantplatform,1/prf); % Update antenna position

      x = step(hwav); % Generate pulse

      [s, tx_status] = step(htx,x); % Transmit pulse


      for n = 3:-1:1 % For each target
      [tgt_pos(:,n),tgt_vel(:,n)] = step(...
      htargetplatform{n},1/prf); % Update target position

      [tgt_rng(n), tgt_ang(:,n)] = rangeangle(...
      tgt_pos(:,n), ant_pos); % Calculate range/angle

      tsig(:,n) = step(hradiator,... % Radiate toward target
      s,tgt_ang(:,n));

      tsig(:,n) = step(htargetchannel{n},...
      tsig(:,n),ant_pos,tgt_pos(:,n),...
      ant_vel,tgt_vel(:,n)); % Propagate pulse

      rsig(:,n) = step(htarget{n},tsig(:,n)); % Reflect off target
      end

      rsig = step(hcollector,rsig,tgt_ang); % Collect all echoes

      rx_pulses(:,m) = step(hrx,... % Receive signal and form
      rsig,~(tx_status>0)); % data matrix
      end
      npower = noisepow(noise_bw,hrx.NoiseFigure,hrx.ReferenceTem perature);
      threshold = npower * db2pow(npwgnthresh(pfa,num_pulse_int,'noncoherent' ));
      num_pulse_plot = 2;
      rangedemoplotpulse(rx_pulses,threshold,...
      fast_time_grid,slow_time_grid,num_pulse_plot);
      matchingcoeff = getMatchedFilter(hwav);
      hmf = phased.MatchedFilter(...
      'Coefficients',matchingcoeff,...
      'GainOutputPort',true);
      [rx_pulses, mfgain] = step(hmf,rx_pulses);
      matchingdelay = size(matchingcoeff,1)-1;
      rx_pulses = buffer(rx_pulses(matchingdelay+1:end),size(rx_puls es,1));
      threshold = threshold * db2pow(mfgain);
      rangedemoplotpulse(rx_pulses,threshold,...
      fast_time_grid,slow_time_grid,num_pulse_plot);
      range_gates = prop_speed*fast_time_grid/2;

      htvg = phased.TimeVaryingGain(...
      'RangeLoss',2*fspl(range_gates,lambda),...
      'ReferenceLoss',2*fspl(max_range,lambda));

      rx_pulses = step(htvg,rx_pulses);
      rangedemoplotpulse(rx_pulses,threshold,...
      fast_time_grid,slow_time_grid,num_pulse_plot);
      rx_pulses = pulsint(rx_pulses,'noncoherent');

      rangedemoplotpulse(rx_pulses,threshold,...
      fast_time_grid,slow_time_grid,1);
      [~,range_detect] = findpeaks(rx_pulses,'MinPeakHeight',sqrt(threshold ));
      true_range = round(tgt_rng)
      range_estimates = round(range_gates(range_detect))

      Comment


      • #18
        Tích phân x/sqrt(5+4x-x^2) cận từ 2 -> 5
        Mình code như sau:
        syms x;
        f=x/sqrt(5+4*x-x*x);
        int(f,x,2,5)
        ra kết quả : pi + 3
        trong khj bấm máy tính CASIO thì k ra đc kết quả.
        Nhờ mọi người chỉ giúp mình làm đúng hay sai & sai thì sửa lại như thế nào ?

        Comment


        • #19
          Anh chị ơi, giúp em bài toán tạo giao diện GUI Matlab này với ạ:
          Em có tạo 1 giao diện GUI gồm 4 nút: 2 nút Drum, 1 nút Record và 1 nút play.
          Tình trạng hiện tại: 1. nhấn vào nút pushbutton Drum1 phát âm thanh Drum 1 (ok)
          2. nhấn vào nút pushbutton Drum2 phát âm thanh Drum 2 (ok)
          3. nút record và play hoạt động
          Vấn đề vướn mắc: Khi nhấn record để thu lại giai điệu mà con trỏ nhấp liên hồi vào hai nút Drum và play lại thì:
          4. tần số hay cao độ của nút Drum được thể hiện lại như khi ta thu (Record)
          5. Khoảng cách giữa hai lần nhấn Drum liên tiếp ko thể hiện lại như khi thu, mà nó được đặt mặc định. Nghĩa là dù có nhấn Drum1 rùi sau 5p mới nhấn Drum2 thì khi play lại khoảng thời gian giữa 2 lần nhấn nút ko phải là 5p mà là mặc định là 0.3s.
          Vấn đề là Nhờ anh chị chỉ giúp em làm sao để khi play nó thể hiện lại đúng thời gian giữa hai lần nhấn PushButton Drum như lúc mình thu đấy ạ!


          % --- Executes just before piano2sua is made visible.
          function piano2sua_OpeningFcn(hObject, eventdata, handles, varargin)
          % This function has no output args, see OutputFcn.
          % hObject handle to figure
          % eventdata reserved - to be defined in a future version of MATLAB
          % handles structure with handles and user data (see GUIDATA)
          % varargincommand line arguments to piano2sua (see VARARGIN)

          % Choose default command line output for piano2sua
          handles.output= hObject;
          handles.SampleRate = 1/20000;
          handles.SoundVector = 0;
          handles.TimeValue= 0.3488;

          % Update handles structure
          guidata(hObject, handles);

          % UIWAIT makes piano2sua wait for user response (see UIRESUME)
          % uiwait(handles.figure1);


          % --- Outputs from this function are returned to the command line.
          function varargout = piano2sua_OutputFcn(hObject, eventdata, handles)
          % varargout cell array for returning output args (see VARARGOUT);
          % hObject handle to figure
          % eventdata reserved - to be defined in a future version of MATLAB
          % handles structure with handles and user data (see GUIDATA)

          % Get default command line output from handles structure
          varargout{1} = handles.output;

          % --- Executes on button press in C5.
          function C5_Callback(hObject, eventdata, handles)
          % hObject handle to C5 (see GCBO)
          % eventdata reserved - to be defined in a future version of MATLAB
          % handles structure with handles and user data (see GUIDATA)

          freq = 523.25;
          PlayNote(handles,freq);

          % --- Executes on button press in D5.
          function D5_Callback(hObject, eventdata, handles)
          % hObject handle to D5 (see GCBO)
          % eventdata reserved - to be defined in a future version of MATLAB
          % handles structure with handles and user data (see GUIDATA)

          freq = 587.33;
          PlayNote(handles,freq);

          function PlayNote(handles,freq)
          % plays the note that was pressed for 1 second
          % also sets the frequency value on GUI for last played note.

          strFreq = num2str(freq);
          set(handles.STFreqValue, 'String', strFreq);

          SampleRate = handles.SampleRate;
          TimeValue= handles.TimeValue;
          Samples = 0:SampleRate:TimeValue;
          SinOn = get(handles.SinWave, 'Value');
          SquareOn = get(handles.SquareWave, 'Value');
          SawtoothOn = get(handles.SawtoothWave, 'Value');

          if SinOn == 1
          soundVector = sin(2*pi*freq*Samples);
          elseif SquareOn == 1
          soundVector = square(2*pi*freq*Samples);
          elseif SawtoothOn == 1
          soundVector = sawtooth(2*pi*freq*Samples);
          end

          sound(soundVector, 1/SampleRate)

          RecordOn = get(handles.Record, 'Value');

          if RecordOn == 1
          SoundVectorLong = handles.SoundVector;
          if SoundVectorLong == 0
          SoundVectorLong = soundVector;
          else
          SoundVectorLong = cat(2, SoundVectorLong, soundVector);
          end
          handles.SoundVector = SoundVectorLong;
          guidata(handles.figure1, handles);
          end

          % --- Executes on button press in Play.
          function Play_Callback(hObject, eventdata, handles)
          % hObject handle to Play (see GCBO)
          % eventdata reserved - to be defined in a future version of MATLAB
          % handles structure with handles and user data (see GUIDATA)

          SoundVector= handles.SoundVector;
          SampleRate = handles.SampleRate;

          sound(SoundVector, 1/SampleRate)

          Cảm ơn anh chị nhiều!
          ptptshana@gmail.com
          01676456942

          Comment


          • #20
            Mình cũng định làm chương trình phát nhạc giống vầy, nhưng bây giờ chưa chạy GUI được nữa. Không biết làm sao mà máy mình giờ nhấn vào push button nhưng nó không chạy callback của push button. Không biết phải ***** MATLAB sai không. Có ai rành chỉ mình với. Cám ơn nhiều.

            Comment

            Về tác giả

            Collapse

            rainbowsmile Tìm hiểu thêm về rainbowsmile

            Bài viết mới nhất

            Collapse

            • bqviet
              Trả lời cho Đấu tắt điện cho máy tính bảng
              bởi bqviet
              Bqv cáo lỗi vì chưa đủ khả năng diễn giải để người đọc hiểu. Người làm kỹ thuật sâu đôi khi như thế đó. Về việc nạp pin không vào dù cell mới, khả năng cái mạch quản lý đó đã hỏng - cũng chính là nguyên nhân đám cell cũ hỏng từ đầu.
              06-12-2025, 17:17
            • nguyendinhvan
              Trả lời cho Xin hỏi về mạch thu FM/AM trong catsette
              bởi nguyendinhvan
              Theo tôi, nó chỉ là cái Tuy- ê - nơ, hoặc là khối Trung Văn Tần, nó một phần trong cái Da đì ô thôi. Vì có thấy một chỗ có ba chân hàn, giiống như chân Cờ rít sờ tăng 455 ki nô hẹc. Còn khối Tuy ê nơ thì không nhìn thây cái Di ốt Va di cáp...
              05-12-2025, 19:59
            • afrendly
              Trả lời cho Đấu tắt điện cho máy tính bảng
              bởi afrendly
              Có vẻ ngoài hiểu biết của mình rồi. Cuối cùng mình quyết định tìm mua 2 pin trên Shopee, giá 200K thay vào. Tuy nhận pin được 1%, sạc mãi không vào nhưng cũng mở được máy lên. Vậy cũng tạm. Cảm ơn bạn đã hỗ trợ nhé....
              04-12-2025, 01:27
            • nick22
              Trả lời cho Máy điện châm ?
              bởi nick22
              Đúng như bạn nói, máy điện châm hiện nay trên thị trường đã khá đa dạng về mẫu mã, chức năng và giá thành.
              01-12-2025, 13:23
            Đang tải...
            X