MATLAB Answers

Illegal use of cell array indexing in 'equations' block

2 ビュー (過去 30 日間)
Rocío Bonilla Villares
Rocío Bonilla Villares 2020 年 10 月 16 日
回答済み: Chidvi Modala 2020 年 10 月 28 日
Hi,
I'm trying to do a non-ideal flowmeter with simscape component reusing the hydraulic flow rate sensor's source data. For that, I want to put that the differential pressure between the nodes (A and B) must be equal to a calculation done outside and introduced as input (P_loss). However, when I compile the error "Illegal use of cell array indexing in 'equations' block" appears. So, does anybody know how can manage that equality without cell arrays indexing? cell2mat does not work either and putting directly p == P_loss neither despite they have the same cell array's values.
component nonideal_flowmeter
inputs
P_loss = {0, 'Pa'}; % P_loss:left
end
nodes
A = foundation.hydraulic.hydraulic; % A:left
B = foundation.hydraulic.hydraulic; % B:right
end
variables
q = {1e-3, 'm^3/s'}; % Flow rate
p = {0, 'Pa'}; % Pressure differential
end
branches
q : A.q -> B.q;
end
intermediates
int_term1 = P_loss{1,1};
end
equations
p == A.p - B.p;
p == {int_term1, 'Pa'};
end
end

回答 (1 件)

Chidvi Modala
Chidvi Modala 2020 年 10 月 28 日
Hi Rocio,
Did you try using the following?
cellfun(@isequal, p, P_loss);

Community Treasure Hunt

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

Start Hunting!

Translated by