How to Store an single row and all columns of a struct in a variable?

3 ビュー (過去 30 日間)
Imtiaz nabi
Imtiaz nabi 2022 年 1 月 31 日
コメント済み: Imtiaz nabi 2022 年 1 月 31 日
Hello, I have a structure which is as follow:
SatGlobal.aChanData(all).PRN
The above structure contains 12 satellite PRN codes inside the PRN property. Now I want to extract this number of satellites and store them into a variable to find the size of the matrix to create a control state for a loop later.
Actually the size of this property varie depending upon the number of available satellites.
I did it somehow in the past but lost that code and I can't remember how I did it actually.
I am currently using the following code but it is giving me only one SV.
Please note that the PRN value is different for each satellite and I want to extract the all available channels.
SV = SatGlobal.aChanData(1,1:end).PRN;
num_sv = length(SV)
for i = 1:num_sv
% run a loop for all calculations
end
% This code only store 1 value in the SV now and first it was storing all
% the available channels

採用された回答

Walter Roberson
Walter Roberson 2022 年 1 月 31 日
SV = [SatGlobal.aChanData(1,1:end).PRN];
provided that the PRN are numeric scalar values.
This could also be written as
SV = [SatGlobal.aChanData.PRN];
provided that aChanData is not 2 or more dimensional.
  1 件のコメント
Imtiaz nabi
Imtiaz nabi 2022 年 1 月 31 日
OMG yes that was exactly I did before lol!
thank you so much

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by