Skip to main content

Posts

Showing posts from September, 2021

Stretch the dynamic range of the given 8-bit grayscale image using MATL...

Custom object class array initilization within Simulink Matlab Function Block

  The summary of my question is I need know how to preallocate an array of custom objects in a way that is compatible with Simulink when using the Matlab Function block in Simulink.   Details: I am attempting to port over some code I have written in Matlab to run as a function in Simulink using the "Matlab Function" block. I have created a custom class called "pulse." (minimal example at the bottom of this question). I want to be able to initialize an array of these pulse objects. My Matlab code works fine now with the call:   pulse_array(1:2,1:4) = pulse; This creates a 2x4 array of pulse objects as expected. The problem I am having is when I use my code within Simulink. When I try to run this same line within the Simulink Matlab Function block I get the error:   Undefined function or variable 'pulse_array'. The first assignment to a local variable determines its class.   It looks to me like the coder doesn't know that pulse_array should be a pulse obje

How to modify the Names in Input and Output tabs of the FMU block from the Command Line/API?

  How to modify the Names in Input and Output tabs of the FMU block from the Command Line/API? ANSWER Matlabsolutions.com  provide latest  MatLab Homework Help, MatLab Assignment Help  for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research. The name fields listed under the "Input" and "Output" tabs cannot be changed via the Command Line/an API method for the FMU file itself. The FMU block takes the names of the signals within the buses fed into the block and they are baked in at the time the FMU block is created. The FMU block must be fed the buses that appear in the Input and Output tabs.    Since it is possible to change this in the FMU block mask for the Simulink instance, you can use the following API to change it in the mask:   To get the actual infor

How to get the file path inside a script, function, or model?

  How can I get the path of the script or function being executed or model being run from inside the file itself? ANSWER Matlabsolutions.com  provide latest  MatLab Homework Help, MatLab Assignment Help  for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research. For scripts and functions:   [filepath,~,~] = fileparts(mfilename('fullpath')) or simply filepath = fileparts(mfilename('fullpath')) Note:   -This works with M file scripts and functions during normal execution.   -This will not produce the desired result for MLX live scripts or in "%%" sections of scripts run individually.   -The functions used are not supported for code generation.   For live scripts (or "%%" sections of scripts):   [filepath,~,~] = fileparts(which('your_file_nam

Connection between two PCs with Simulink

  I am doing a master degree project and it is based on Hardware-in-the-loop (HIL) to a quadrotor model. The difference between common projects I will not use a external hardware (like a board, Arduino), I will use an other computer (PC) to be the hardware and run the controller block of my model. That is, I want run a model in   Simulink   (PC1) but only the controller block must run in the PC2 and the two PCs has to exchange the informations (inputs and outputs of this controller block).   How can I do it?? ANSWER Matlabsolutions.com  provide latest  MatLab Homework Help, MatLab Assignment Help  for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research. The solution depends on whether you need real-time performance. If real-time performance is not needed, then you can run Simu

Simulink HDL Coder D-FF With Trigger that isn't clock

  Hello, im trying to build a D-FF using HDL Coder in   Simulink   without a clock trigger   signal . The trigger signal I desire is generated outside the subsystem and fed as an input to the subsystem. Whenever I convert the model into HDL, inputs that are not included in the subsystem are added (such as clk, clk_enable). Is there a way to model a DFF with a trigger signal that is not a system clock and translate it into HDL using HDL Coder?   The generated HDL code should be something like this:   ------------------------------------------------------------------------------------------------ always @(posedge  trigger_signal  or negedge rst) begin if (!rst) v_sampled_latched <= pi_ref; else v_sampled_latched<=v_sampled_masked; end ------------------------------------------------------------------------------------------------ I have tried using delay block and triggered subsystem, both add undesired inputs to the system, and use those inputs as trigger to the DFF instead of the

Amplitude of FFT is not correct

  Hey there,   i want to calculate the power output of a 3 phase inverter. Therefore i have to do a FFT on my voltage  Signals , to get the amplitude of the fundamental.   In comparison to the FFT Tool from the  Simulink  powergui, my amplitude is always lower. I searched for some examples for a correct scaled FFT, but i cant find differences to my code.   f1 = ac_voltage_a.data(SteadyState:1:SteadyState+2^15); % A Timeseries vector is used when system is in steady state g1 = hanning(length(f1)).*f1; % Using the hanning window dt=Tsample % Tsample = 1e-6 vac_fenstera_Nfft = length(g1); % Sampled values J = fft(g1); % FFT vac_fenstera_sfft = 2*abs(J)/vac_fenstera_Nfft; % plot(1/dt * (0:(vac_fenstera_Nfft/2-1)) / vac_fenstera_Nfft, (vac_fenstera_sfft(1:vac_fenstera_Nfft/2))); In comparison to the FFT analysis tool from powergui, the value of my fundamental amplitude is only half the size, even i mutiplied the abs*2.   Where is my fault?   Is it nessesary that the length of g1 is a

SimEvents - Setting Entity Attributes based on other entities

  My app needs to assign an entity attribute in Entity1 based on an attribute value in Entity 2.   I can use a function GetAttribute to get a specific attribute from Entity 1, but how do I assign that to an attribute in entity 2? ANSWER Matlabsolutions.com  provide latest  MatLab Homework Help, MatLab Assignment Help  for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research. You can implement this in two ways. The first approach is easier, and can be implemented via existing SimEvents blocks, but can only be used in special cases of time-driven entity generation. The second approach requires learning how to work with a new block, but has the superiority to be used in event-driven entity generation.   1.  Via Simulink function or Data store.  When Entity1 enters the prespecified

Reverting Referenced Subsystems back to normal Subsystems

  Hi, I use   MATLAB/Simulink  R2019b and its new feature: Subsystems Reference.   During develpoment I use referenced subsystems since they are used in multiple models.   Before the models are distributed to customers, the referenced subsystems must be reverted back to 'normal' subsystems for various reasons.   Since MathWorks does not provide a feature for this behavior I wrote some code in order to do it. In this code I use the 'expand subsystem' feature to break the referenced subsystem links.   Now I have to change my MATLAB/Simulink version to R2020a and suddenly the expand subsystem feature no longer works for referenced subsystems. This change is not documented in the release notes or anywhere else.   Has anyone an idea how I can change my referenced subsystems back to 'normal' subsystems without copying the whole content from one subsystem into antoher one? ANSWER Matlabsolutions.com  provide latest  MatLab Homework Help, MatLab Assignment Help  for stu

How to fix error in port widths or dimentions on the reshape block input?

  I need to make DCT image compression in   Simulink . Image size by default has 3 dimensions, so I used reshape tool to remove the third dimension. Color Space Conversion tool only accepts 3 dimensional images, so I used reshape again.   When I try to run the  simulation , I get two following errors:   Error in port widths or dimensions. ' Output Port 1 ' of ' untitled/2-D IDCT ' is a [512x512] matrix.   Error in port widths or dimensions. ' Input Port 1 ' of ' untitled/Reshape1 ' has 786432 elements. This port does not accept the dimensions (or orientation) specified by the input signal.   I thought reshape was supposed to accept any matrix as an input. ANSWER Matlabsolutions.com  provide latest  MatLab Homework Help, MatLab Assignment Help  for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB pr

Why do graphics disappear from my HTML Doc Block when

  Why do graphics disappear from my HTML Doc Block when I close and reopen the model in Simulink 6.5 (R2006b)? In my  Simulink model , I add a Doc Block whose 'DocumentType' parameter specifies "HTML". Afterward, I add both text and images to the HTML Doc Block.   If I close and reopen my Simulink model and then double-click the Doc Block to access its associated HTML editor, all of my graphics appear to be missing. Instead, I see a red "X" where my graphics were previously located in the HTML document. ANSWER Matlabsolutions.com  provide latest  MatLab Homework Help, MatLab Assignment Help  for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research. This issue results from how your system's HTML editor handles graphics referenced in HTML files.