how to multiply vector and matrix

Hello there,
i need your help. i got two question
1. i have a :
col=1;
t=0:(1.5/10):1.5;
for i=1:length(t)
if col<11
m1=magnitudeL(1,col);
m2=magnitudeL(1,col+1);
m3=m2-m1;
acceL(1,col)=[m3/((1.5/10).^2)];
end
col=col+1;
end
how can i plot the graph of plot(t,accel) ? everytime its return error =
Error using plot Vectors must be the same lengths.
i understand the array not same, but i can't modify * acceL * to be same as t.
2. i have a
Lversor=[x;seatoff;z];
i need this vector to multiply with f and M .i.e :
forceMa=m*acceL*Lversor;
where m is a constant and acceL is an array.acceL is same like coding above. is it posible to do that?
thank you.

2 Kommentare

Roger Stafford
Roger Stafford am 24 Dez. 2014
In 1. how would you suggest a plot be made using more 't' values than 'acceL' values, namely 11 against only 10? What would such a plot look like?
In 2. where you write "m*acceL*Lversor" the second asterisk sign is understood in matlab to be matrix multiplication, and this always requires that the number of columns in 'acceL' be the same as the number of rows in 'Lversor'. Otherwise Matlab will always give you an error message. I suggest you specify precisely what numerical computations you want to see used to obtain 'forceMa' without using matlab syntax and see if we can come up with an algorithm that accomplishes it.
m
m am 25 Dez. 2014
1. i need it, because in 'm3' i need to get the different value of 'magnitudeL[2]-magnitudeL[1]'. and that value to plot graph 'acceL' vs 't'.
2.it's a formula derive from an equation.
F=ma.L versor - mg.L Versor

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 24 Dez. 2014

1 Stimme

Try this:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
numberOfElements = 11; % Whatever.
magnitudeL = rand(1,numberOfElements) % Sample data
t= linspace(0, 1.5, numberOfElements)
acceL = zeros(1, numberOfElements-1);
for k = 1 : numberOfElements-1
m1 = magnitudeL(1,k);
m2 = magnitudeL(1,k+1);
m3 = m2 - m1;
acceL(k) = m3 / ((1.5/10).^2);
end
plot(t, magnitudeL, 'bo-');
grid on;
hold on;
plot(t(1:length(acceL)), acceL, 'rd-');

3 Kommentare

m
m am 25 Dez. 2014
thank you, i manage to plot the graph.
would you mind tellig me what this line acctually do? coz, i learning matlab coding by myself.
plot(t(1:length(acceL)), acceL, 'rd-');
would you mind help me with the second question?
thank you and happy holiday.
Image Analyst
Image Analyst am 25 Dez. 2014
acceL is one element shorter than t so I can't plot it vs. t - I have to plot it versus all but the last element of t, which is what t(1:length(acceL)) gives me. 'r' meand red. 'd' means diamond. '-' means to put a solid line between the data points.
m
m am 30 Dez. 2014
i have change the coding, and now i have more element in acceL compare to t, but i want to ommit the first element of acceL like :
plot( t,acceL ( but accel start with element[1]))
thanks

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Hilfe-Center und File Exchange

Gefragt:

m
m
am 24 Dez. 2014

Kommentiert:

m
m
am 30 Dez. 2014

Community Treasure Hunt

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

Start Hunting!

Translated by