How to save a vector 1x k in each element of an m by n matrix?

1 回表示 (過去 30 日間)
ilyes louahem m'sabah
ilyes louahem m'sabah 2022 年 3 月 8 日
I'vehe following example:
for x=1:368
for y=1:3
for k=1:8760
I've different lines inclusing soc(k)
soc(k)= it has its equation
end %end k loop
% i tried this line but didn't work: SC(x,y)=soc(k);
y=y+1;
end % end y loop
x=x+1;
end % end x loop
For each combination of x,y i want to save soc(k) such that when i get the best combination of x,y i can get soc(k) related to x,y as shown in the code SC(x,y)=soc(k);

採用された回答

Davide Masiello
Davide Masiello 2022 年 3 月 8 日
clear,clc
for x=1:368
for y=1:3
for k=1:8760
soc(x,y,k)= it has its equation
end
end
end
if you want soc(k) at x=5 and y=8 you can write
soc(5,8,:)
Additionally, consider that intelligent vectorization of the above problem could spare you from using loops altogether.
  3 件のコメント
ilyes louahem m'sabah
ilyes louahem m'sabah 2022 年 3 月 8 日
Great! Thank you.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSystem on Chip (SoC) についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by