MATLAB Answers

I am struggling to get started on this MATLAB question. Any tips on how to use for loops in this? Or important things to take note of?

조회 수: 10(최근 30일)

채택된 답변

Image Analyst
Image Analyst 2021년 9월 16일
편집: Image Analyst 2021년 9월 16일
Do you know how to program in the MATLAB language yet?
Here's a start
sa = 32760; % Surface area
wallHeight = 26;
data = readmatrix('data_river_discharge.dat');
inputRate = data(:, 1); % Column 1 is the river input charging rate (into the lake).
outputRate = data(:, 2); % Column 2 is the discharge rate from the dam (out of the lake).
numTimePeriods = size(data, 1); % Number of rows. Each row is a different time point.
for k = 1 : numTimePeriods
% Code goes here
if waterLevel > 0.8 * wallHeight
% Goes over spillway.
Qout =
elseif waterLevel < 0.3 * wallHeight
% Reduce outflow
Qout =
else
% Normal operating condition.
end
% Get water level at end of this time period
waterLevel = something involving prior water level and Qout and Qin
end
  댓글 수: 7
Ned Williams
Ned Williams 2021년 9월 18일 4:22
clc;close;clear
format short g
data=xlsread('data_RiverDischarge.xls');
sa=352760;
H=26;
vol=sa*H;
Rin=data(:,1);
days=size(data,1);
y(1)=18.8;
Qin=data;
Qout=5.33;
Qr=2.2*Qout;
for i=2:1:days
I(i-1)=(Qin(i-1))/sa
O(i-1)=(Qout(i-1))/sa
R(i-1)=(Qr(i-1))/sa
y(i)=y(i-1)+I(i-1)-O(i-1)-R(i-1)
p=y(i)/H
for Q=Qout
if p>0.3 && p<0.8
Q=5.33; Qr=0
elseif p>0.8
Q=5.33;Qr=2.2*Qo
elseif p<0.3
Q=(1/1)*Qin(i)
else p>=1
disp('overflow')
end
end
y(i+1)=y(i)+I(i)-O(i)-R(i)
p=(y(i+1))/H
end
Does this make any more sense> I am still getting an error saying that the Index exceeds the number of array elements (1)

댓글을 달려면 로그인하십시오.

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by