How to plot the value in a graph (that i circled) with a MATLAB Function ?

1 次查看(过去 30 天)

回答(1 个)

Walter Roberson
Walter Roberson 2022-4-29
To do that through commands, you could have code that first copied the .slx file to a different model. Then use a bunch of set_param() commands to delete all blocks except the MATLAB function block and the solver configuration. Now create an N x 3 array at the MATLAB level in which the first column is a series of times, and the other two columns are P and V values. Now use set_param() commands to construct a From Workspace block that imports that N x 3 array from your MATLAB workspace. Then use set_param() commands to turn on signal logging on the block outputs that you will want to plot.
With all that in place, you can now use sim() to run the MATLAB function with those inputs. You would then examine the logged data in the output from sim() and use it to plot()
This kind of thing is needed to plot the outputs of the MATLAB Function Block that you have circled and do so "with a MATLAB Function". It would typically be far easier to just add signal logging in the original model, and run the entire model, and then examine the logged output.
I would point out to you that the plot that you circled points on, is the I-V plot, which is being plotted by the block labeld I-V that is two blocks vertically above the MATLAB Function Block -- and the MATLAB Function Block is not needed at all to plot I-V . The blocks needed to produce the I-V plot are the "PV Module 60 WP" and possibly items off-screen to the left of it. Turn on signal logging for the I and V outputs, run the model, examine the logged signals at the MATLAB level, do the plot,.
  2 个评论
Dimas Lugia Hardianto
编辑:Walter Roberson 2022-4-29
i use this code in the MATLAB function
function [max_Pmpp, max_Vmp, max_Imp] = max_val(P,V)
persistent Pmpppre Vmpppre Imppre
if isempty(Pmpppre)
Pmpppre = 0;
Vmpppre = 0;
Imppre = 0;
end
if (Pmpppre > P)
max_Pmpp = Pmpppre;
max_Vmp = Vmpppre;
max_Imp = Imppre;
else
max_Pmpp = P;
max_Vmp = V;
max_Imp = P/V;
end
Pmpppre = max_Pmpp;
Vmpppre = max_Vmp;
Imppre = max_Imp;
So can you explain about how to know plot graph maximum point of x axis and y axis?
Walter Roberson
Walter Roberson 2022-4-29
If you had access to all of the P, V values at the same time (because you were executing at the MATLAB level instead of inside Simulink), then the code becomes equivalent to:
[max_Pmpp, maxidx] = max(P(:));
if maxP > 0
max_Vmp = V(maxidx);
max_Imp = max_Pmpp ./ max_Vmp;
else
max_Pmpp = 0;
max_Vmp = 0;
max_Imp = 0;
end

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 View and Analyze Simulation Results 的更多信息

标签

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by