pulling a value from a column matrix

2 views (last 30 days)
C Mck
C Mck on 14 Jul 2016
Commented: Star Strider on 14 Jul 2016
hi,
does could anyone tell me why
output(57,1) = E(35)
returns this:
output=
0
0
0
0
0
0
0
12735.844108
0
0
0
0
0
35722.575872
0
0
0
0
0
345.48072942
0
0
32.212963692
589.65336604
28.428010548
0
0
0
74.661832664
0
0
0
132.86355058
0
309.87304412
0
0
0
0
0
0
0
0
0
0
106.89594308
0
0
402.70431968
0
347.0927026
0
140.7713078
0
0
0
115.04715948
rather than just
output =115.04715948
Thanks

Answers (2)

Star Strider
Star Strider on 14 Jul 2016
It seems ‘E’ is a cell array.
Perhaps this will do what you want:
output(57,1) = E{35}
or:
output(57,1) = E{:}(35)
A guess, since I don’t have your data.
  2 Comments
C Mck
C Mck on 14 Jul 2016
that doesnt seem to work.
this is E
E =
508.81672092
12735.844108
35722.575872
417.5112887
4202.3748734
345.48072942
2611.2314224
32.212963692
589.65336604
28.428010548
37.775767244
71.709872416
71.21449203
74.661832664
191.76442214
151.38876054
92.089877226
132.86355058
208.40229084
4337.0593162
119.3678733
309.87304412
248.68896544
71.645115216
153.74833606
106.89594308
402.70431968
347.0927026
140.7713078
85.999836222
1123.84165
84.386988728
66.776172482
40.626996846
115.04715948
95.863836564
648.20320762
101.232009776
1799.0496216
98.412884954
8704.9007068
1067.7063004
924.66060622
Star Strider
Star Strider on 14 Jul 2016
You’re not actually looking at ‘E’, you’re looking at ‘output(57,1)’, so row 57, column 1 of ‘output’, to which you have just assigned ‘E(35)’.
For example:
output(10,1) = E(35)
output =
0
0
0
0
0
0
0
0
0
115.05
It displays the entire column because you asked it to, with ‘E(35)’ now assigned appropriately.

Sign in to comment.


Azzi Abdelmalek
Azzi Abdelmalek on 14 Jul 2016
Look at this example
a=[0 0 0 1 0 0 2 0 0 3 0 0 0 4 5]
b=[6 7 8 9 10]
a(6)=b(3)
%The last line will display all the values of a, if you want to display one value
a(6)=b(3);
a(6)

Tags

Community Treasure Hunt

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

Start Hunting!