Need some help with function call
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello
I am trying to call this function from a code in m-file.
function [] = DiffOCV( k,DYNData,model)
OCVfromSOC(DYNData.soc(k+1),model) ...
- OCVfromSOC(DYNData.soc(k),model) ...
/DYNData.soc(k+1) ...
-DYNData.soc(k)
end
Please note that:
1. 'DYNData' is a structure variable in some .mat file called ECE5550data.mat,
2. 'model' is a structure variable in some .mat file called ECE5550cell.mat and
3. OCVfromSOC(zk,model) is some another function
And all these are actually in the same folder and path as the m-file I am trying to execute. I need to call this function(described above as 'DiffOCV') in my m-file so that it can return me a value that I can use. How can do this. I know I am screwing the way I am passing input arguments or the way I am calling the function. Need to learn both. Please help if you can.
Thanks
댓글 수: 0
답변 (1개)
Guillaume
2014년 12월 10일
Well, for the function to return you a value that you can use, you need to declare that return value in the function signature and assign the result of the computation to it:
function out = DiffOCV(k, DYNData, model)
out = OCVfromSOC(DYNData.soc(k+1),model) ...
- OCVfromSOC(DYNData.soc(k),model) / DYNData.soc(k+1) ...
- DYNData.soc(k);
end
참고 항목
카테고리
Help Center 및 File Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!