MATLAB Answers

how separate the first one (Xp) from (Xn).?

조회 수: 5(최근 30일)
now when I compleat the first signal, But now I want to separate Xn from Xp in the following
rs=[Xn, Xp]
but the length of Xn and Xp is different, therefor we truck the length
XNsize = length(Xn);
rf =[XNsize, Xp, Xn];

채택된 답변

John D'Errico
John D'Errico 26 Feb 2019
편집: John D'Errico 26 Feb 2019
I have no idea why you are trying to do this using a vector. Far better would be to store your variables in a struct or a cell array. For example,
rs = {Xn,Xp};
Now you can recover Xn of Xp as simply rs{1} or rs{2}.
Or use
rs.Xn = Xn;
rs.Xp = Xp;
Here you extract Xn or Xp using rs.Xn or rs.Xp.
In either case, Xn and Xp are easily extracted. You need never pack the length of Xn into the vector, a kludge that serves no purpose, since in order to use those variables, you need to unpack them anyway.
Can you unpack the result from the vector? OF COURSE YOU CAN! But the point is, packing it all into a vector serves no purpose, especially since you have no idea how to unpack them in the first place. Yes, you are still out there, asking but if I really, really, really must do it the way I desperately wanted to do it, how would I have solved the problem using the kludge of packing it all into a vector?
Xn = rf(2:rf(1)+1);
Xp = rf(2 + rf(1):end);
Again, better would be just to learn to use MATLAB. Then you don't need to use a kludge solution in the first place.
  댓글 수: 4
John D'Errico
John D'Errico 26 Feb 2019
And I have no idea what you are asking in your followup question, which seems totally unrelated to this question. If you have another question, then ask it separately. And if you want a useful answer, then be more clear about what you mean by the words "reshape" and "damage", as they have no meaning on their own. Only you know what they mean to you.

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

추가 답변(1개)

abdullah qasim
abdullah qasim 26 Feb 2019
thank u very much
All the appreciation to you thank you very much

Community Treasure Hunt

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

Start Hunting!

Translated by