フィルターのクリア

for loop n*n matrix with a given formula

2 ビュー (過去 30 日間)
Lodewijk Pleij
Lodewijk Pleij 2018 年 3 月 5 日
回答済み: YT 2018 年 3 月 5 日
I want to write a code for the following problem:
The code must be able to determine the head (h) at every x and y. I have constructed the formula, and now I want to construct a n*n matrix for every head at every position with a for loop. I have constructed the following:
%%Example 7.1
A=(-4/500);
B=(-2/300);
C=120;
x=-100:10:600;
y=-600:10:100;
h=zeros(71);
for i=1:71
h(i,:)=A*x(i)+B*y(71)+C;
h(:,i)=A*x(1)+B*y(72-i)+C;
end
Thanks in advance.
  2 件のコメント
Bob Thompson
Bob Thompson 2018 年 3 月 5 日
What exactly do you need help with?
Stephen23
Stephen23 2018 年 3 月 5 日
@Lodewijk Pleij: what is your question?

サインインしてコメントする。

回答 (1 件)

YT
YT 2018 年 3 月 5 日
I assume your looking for something like this, so you'll end up with a matrix h with size 71x71 (rows = x, columns = y)
clear all;
close all;
A = (-4/500);
B = (-2/300);
C = 120;
x = -100:10:600;
y = -600:10:100;
n = size(x,2);
h = zeros(n);
for i = 1:n
for j = 1:n
h(i,j) = A*x(i) + B*y(j) + C;
end
end

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by