You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
Can someone please tell me where is my fault?
Accepted Answer
27 Comments
I do not understand why you have M_ter and I_phod listed as parameters but you then read M_ter from a file and you use a constant for I_phod . I think you have constructed your flow incorrectly.
I have written the below code following your logic.
One of the parts that I was not certain of was whether your Moment_terecenja file is intended to have multiple rows. The sizes of your variables were not consistent if it could have multiple rows, so in the code I assumed that there should be only one row. I assumed that there were a maximum of 64 values on that one row.
Is your Moment_terecenja a text file or a .xls file? Please describe the content for it, the number of fields and the number of rows. An example might help.
First I introduce a new function to fetch the M_ter. I think you should not have to do this, as I think you should be passing it as an input to your blocks. However, I assume you had a reason for reading it from the file instead of using the parameter passed. By putting the code in a function of its own, we only have to get it right once.
None of this code has been tested. I am working from the documentation, as I have never had access to the Simulink software.
function M_ter = get_Mter() %this is a new function. It must be stored in get_Mter.m
coder.extrinsic('xlsread'); filename = 'Moment_terecenja' ;
coder.varsize('T', [1 1]); T = zeros(1,64); T = xlsread(filename) ;
M_ter = zeros(1,1); M_ter = T(1,1);
First block
function nnovo = fcn(n, M_ter, I_phod)
I_phod = 4.17 ; n_phod = 1498 ;
M_ter = zeros(1,1); M_ter = get_Mter();
nnovo = zeros(1,1) ; nnovo = -0.0284 * M_ter.^2 - 1.3569 * M_ter + n_phod ;
Second block
function I = fcn(n, M_ter, I_phod)
I_phod = 4.17 ;
M_ter = zeros(1,1); M_ter = get_Mter();
I = zeros(1,1) ; I = 0.0033 * M_ter.^2 + 0.1019 * M_ter + I_phod ;
Third block
function eta = fcn(n, M_ter, I_phod)
M_ter = zeros(1,1); M_ter = get_Mter();
eta = zeros(1,1) ; eta = -0.001 * M_ter.^2 + 0.0588 * M_ter ;
Fourth block
function cos_phi = fcn(n, M_ter, I_phod)
M_ter = zeros(1,1); M_ter = get_Mter();
cos_phi=zeros(1,1) ; cos_phi = -0.0008 * M_ter.^2 + 0.0542 * M_ter - 0.3941 ;
I still do not understand about the Ramp or why M_ter is being read from a file instead of being passed as a signal, or why you are passing I_phod as a signal but ignoring the value. Still here is the version with 7 values expected for M_ter
function M_ter = get_Mter() %this is a new function. It must be stored in get_Mter.m
coder.extrinsic('xlsread'); filename = 'Moment_terecenja' ;
coder.varsize('T', [1 0]); T = zeros(64,1); %we only expect 7 values but allow up to 64 before we bomb T = xlsread(filename) ;
M_ter = zeros(7,1); M_ter = T(1:7,1);
First block
function nnovo = fcn(n, M_ter, I_phod)
I_phod = 4.17 ; n_phod = 1498 ;
M_ter = zeros(7,1); M_ter = get_Mter();
nnovo = zeros(7,1) ; nnovo = -0.0284 * M_ter.^2 - 1.3569 * M_ter + n_phod ;
Second block
function I = fcn(n, M_ter, I_phod)
I_phod = 4.17 ;
M_ter = zeros(7,1); M_ter = get_Mter();
I = zeros(7,1) ; I = 0.0033 * M_ter.^2 + 0.1019 * M_ter + I_phod ;
Third block
function eta = fcn(n, M_ter, I_phod)
M_ter = zeros(7,1); M_ter = get_Mter();
eta = zeros(7,1) ; eta = -0.001 * M_ter.^2 + 0.0588 * M_ter ;
Fourth block
function cos_phi = fcn(n, M_ter, I_phod)
M_ter = zeros(7,1); M_ter = get_Mter();
cos_phi=zeros(7,1) ; cos_phi = -0.0008 * M_ter.^2 + 0.0542 * M_ter - 0.3941 ;
More Answers (0)
See Also
Categories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)