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

2 views (last 30 days)
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 Comment
Joao Gocan
Joao Gocan on 10 Feb 2021
Already solved it: https://uk.mathworks.com/matlabcentral/answers/265065-question-about-finding-y-value-for-certain-x-value-of-a-plot#answer_207309

Sign in to comment.

Answers (0)

Categories

Find more on Line Plots in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!