Setting array value fail/pass depending on method



error: =: nonconformant arguments (op1 is 4x1, op2 is 1x3)
error: called from
wp at line 68 column 15
view_digs at line 129 column 1


        t(:,j)=[tv(n).t ti(2)];
        v(:,j)=[tv(n).v tv(n).v(end)];

but I can’t see why the 1st method fails…

Could you show a complete minimal example that reproduces the issue for you?

This case is minimal:
testb.m (363 Bytes)
Maybe I’m using the ‘struct’ wrongly somehow…
I guess it needs ‘zero padding’ adding somehow to make it same length.
It is maybe quite difficult to padding the zeroes…
So I will just change the strategy:
This would work:
testc.m (425 Bytes)
but in latter case some issues with ‘stairs’:

error: stairs: X and Y must be numeric 2-D vectors or matrices
error: called from
    stairs>__stairs__ at line 126 column 7
    stairs at line 104 column 17
    wp at line 86 column 12
    /home/jari/bin/view_digs.m at line 139 column 1

If in case of ‘stairs’ or ‘plot’ as below:
plot (x, y, “or”, x, y2, x, y3, “m”, x, y4, “+”)
how can I enter the structure here (where each x-y -pair has different length)?
latter case it should work maybe as ‘plot(ts,vs)’, but not possible…
The ‘stairs’ can be handled inside the loop as:

hold on;
for j=1:2,
  [pt(j).v, pv(j).v]=stairs(ts(j).v,vs(j).v);

if I use the ‘hold on’, it can plot them one by one in same window/field.
i think it is solved by changing different method (using with ‘hold on’).

This case it looks more complicated form is needed:
where it can not be directly entered in to the plot with the stairs…
Of course the same marking has different meaning when at the left of the ‘=’ sign and when at the right of the equal sign:

[pt, vt]=[5, 1]
error: invalid number of output arguments for constant expression

You are using end+1 in a loop. On each repetition, that would append a new row to your matrix.
So the sizes no longer match after the first repetition.

that is correct also, but it doesn’t seem possible to work at all (even with wrong result).
The code is wrong, but it might be still be able to run… but not sure.
The below code would work, but is too complicated:
testd.m (364 Bytes)
I think it is just caused because array’s must have same size.


would be most likely the best method…