Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How do I derive a linear equation for wind speed between 13km/h –50km/h using “if-else”?

조회 수: 1 (최근 30일)
for i = 1: length(Wind_Year)
if WindLight = nnz((Wind_Year >= 13) & (Wind_Year < 50));
Power = m * x + c;
Power = m * WindLight + c;
Power1 =[Power1; Power];
Day1 = [Day1; i];
elseif WindHeavy = nnz((Wind_Year >= 50) & (Wind_Year <= 100));
Power = m * x + c;
Power = m * WindHeavy + c;
Power2 = [Power2; Power];
Day2 = [Day2; i];
end
end
The data (13 - 50) and (50 - 100) is coming from 12 spreadsheets.

답변 (1개)

Andreas Bernatzky
Andreas Bernatzky 2020년 6월 22일
you have to index Wind_Year with your increment i.
For example Wind_Year(i) but heavily depends on what type of container your Wind_Year variable belongs to (Table,Vector,Cell...)
  댓글 수: 2
Thomas Portsmouth
Thomas Portsmouth 2020년 6월 22일
source_directory = 'C:\Users\thoma\OneDrive\Desktop\Project 1';
source_file = dir(fullfile(source_directory, '*.csv'));
Wind_Year = [];
for i = 1: 12
file_name = fullfile(source_directory,source_file(i).name);
file_data = xlsread(file_name);
Wind_Month = file_data(:, 7);
Wind_Year = [Wind_Year; Wind_Month];
end
This is where my Wind_Year is coming from, its 12 spredsheets of data.
Andreas Bernatzky
Andreas Bernatzky 2020년 7월 27일
Hello Thomas,
sorry for the late reply. Maybe you can attach one of the (shorter) excel-Sheets?
Than I can have a better look on it.
Your code looks ok to me for iterating over all sheets.

이 질문은 마감되었습니다.

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by