How to collect Y values in graph plot in MATLAB APP Designer other than indexing?

1 次查看(过去 30 天)
I keep getting the error: "Array indices must be positive integers or logical values." whenever I try to run my code.
I have a plot of delta Tc (the change in temperature for the refrigerant) against its flow rate. The problem is I would like to be able to collect the specific delta Tc values just by changing the discrete knob for the flowrate. The option I have found so far was indexing, however it does not accept values that are not integers. Can someone help me?
function CalculateButtonPushed(app, event)
t = readtable("flowrates.xlsx","Sheet",1);
Hrate = str2num(app.HotFlowrateLminKnob.Value);
Hin = str2num(app.HotFluidTemperatureInCListBox.Value);
flowrateC = str2double(app.ColdFlowrateLminKnob_2.Value);
specific_heat = 4200;
if Hrate == 1 && Hin == 60
x = table2array(t(:,"Fc1Lm60H"));
y = table2array(t(:,"delta_Tc1"));
plot(app.UIAxes,x,y);
delta_TC = y(flowrateC);
app.deltaTcEditField.Value = delta_TC;
heat_transferred = (flowrateC/60)*specific_heat*delta_TC;
app.HeattransferredJoulesEditField.Value = heat_transferred;
app.Lamp.Color = "g";
  1 个评论
Joao Gocan
Joao Gocan 2021-2-10
Already solved it: https://uk.mathworks.com/matlabcentral/answers/265065-question-about-finding-y-value-for-certain-x-value-of-a-plot#answer_207309

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by