How to plot the value in a graph (that i circled) with a MATLAB Function ?
1 次查看(过去 30 天)
显示 更早的评论
回答(1 个)
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 个评论
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 Center 和 File Exchange 中查找有关 View and Analyze Simulation Results 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
