- The range for "Ub" appears to be incorrect. The correct syntax for using ‘for’ loop with a step size counter would be “Start value: Step size : End value”. However, in the first line of code, it is specified that ‘for Ub = ( 378:462:10.5)’ which signifies that step size (462) that is larger than the range itself. Please adjust the range accordingly. You can refer to the below documentation to know more about the usage of “for” loop in MATLAB: https://www.mathworks.com/help/matlab/ref/for.html
- It seems that you are using the same variable names "PR" and "QL" for both the loop counters and the loop variables. To avoid confusion and errors, it is better to use different variable names.
- Inside the nested loops, you need to calculate the values of "P" and "Q" based on your specific requirements.
I want to save dat from Simulink into a file without overwritting the previous results
2 ビュー (過去 30 日間)
古いコメントを表示
Hi everyone!
I am triying to save P and Q results in a file or in a txt but the code doesn´t run properly.
for Ub=(378:462:10.5)
PR=0;
QL=0;
while (PR~=100000 && QL~=100000)
for PR=(0:100000:25000)
for QL=(0:100000:25000)
Pact=P;
Qreact=Q;
save ('PQ.txt','P','Q','-ascii','-append')
end
end
end
end
0 件のコメント
回答 (1 件)
Lokesh
2023 年 9 月 25 日
Hi Martin,
I understand that you want to save data from Simulink into a file without overwriting the previous results.
The "save" function is correctly used to save the values of P and Q to a text file named 'PQ.txt'. The '-append' flag ensures that the data is appended to the file rather than overwriting it on each iteration.
However, there are a few issues with the code you provided. Here are some suggestions for the same:
I hope this resolves your issue.
Best Regards,
Lokesh
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Simulink Functions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!