1
$\begingroup$

I have two lists with different lengths and would like to transfer them to excel with the titles "Normalx+" and "Normaly+" respectively. I am using the following script, although it works but generates the following error message

Error message: PadRight::ilsm: List of machine-sized integers expected at position 2 in PadRight[{{0.314695,0.202724,0.445823,0.137051,0.340344,0.210384,0.0014843,-0.00337419,0.115197},{0.525304,0.0501755,0.796942,0.167022}},P].

Normalxp = {0.314695, 0.202724, 0.445823, 0.137051, 0.340344, 
  0.210384, 0.0014843, -0.00337419, 0.115197}
Normalyp = {0.525304, 0.0501755, 0.796942, 0.167022}
Firstraw = {"Normalx+", "Normaly+")}
Transpose[
  PadRight[{Normalxp, Normalyp}, P]];
P11 = % /. P -> Sequence[]
P12 = Insert[P11, Firstraw, 1]
P12 // TableForm
Export["RMS-Cropped.xls", P12]

I would like to know what the reason is and how I can solve the issue? Thank you!

$\endgroup$
2
  • $\begingroup$ What is P? PadRight needs a number there. $\endgroup$ – flinty Jul 11 '20 at 21:34
  • $\begingroup$ Thank you Flinty! I found this method from the Possible issues section on the Transpose page: reference.wolfram.com/language/ref/Transpose.html. I think it is a random variable which can be added and then removed. $\endgroup$ – Mehdi Ebadi Jul 11 '20 at 21:54
3
$\begingroup$

You need to tell PadRight up to what dimension to pad. In your case you would want something of dimension {2,9}, so this should work:

Normalxp = {0.314695, 0.202724, 0.445823, 0.137051, 0.340344, 
  0.210384, 0.0014843, -0.00337419, 0.115197};
Normalyp = {0.525304, 0.0501755, 0.796942, 0.167022};
Firstraw = {"Normalx+", "Normaly+"};
Transpose[
  PadRight[{Normalxp, Normalyp}, {2,9}, P]]
P11 = % /. P -> Sequence[]
P12 = Insert[P11, Firstraw, 1]
P12 // TableForm
Export["RMS-Cropped.xls", P12]
$\endgroup$
1
  • $\begingroup$ Thank you! Yes, it is solved! $\endgroup$ – Mehdi Ebadi Jul 11 '20 at 22:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.