Hi Zaheer,
AS per my understanding, the errors are getting generated due to the following:
- Qdt is undefined: You are using Qdt(i) before it’s defined. You should initialize Qdt before the loop, similar to how you initialized SOC0. For example, you can add Qdt = zeros(size(t)); before the loop.
- M and N are not in the same array: In your code, M and N are calculated inside the loop, but it seems like you forgot to define b which is used in the calculation of N. You need to define b before you can calculate N.
- Vector not in same length for Figure 1: This could be because the vectors bring plot have different lengths. Ensure that t and SOC have the same length. You can check this with length(t) and length(SOC).
- Cannot receive variable x for Figure 2: This might be because x is not defined for all time points. Make sure that x is defined for each point in time t.
Regarding the Battery Pack model and bidirectional parameters, they seem to be defined correctly as per your comments. Without a deeper understanding of the specific application and the mathematical model used, it is hard to say if the parameters are correct. You might want to double-check the values and units of the parameters to make sure they are correct for your specific application.
Hope this helps!